• 学习uboot sandbox

1.Sandbox

  The ‘sandbox’ architecture is designed to allow U-Boot to run under Linux on almost any hardware. To achieve this it builds U-Boot (so far as possible) as a normal C application with a main() and normal C libraries.

  All of U-Boot’s architecture-specific code therefore cannot be built as part of the sandbox U-Boot. The purpose of running U-Boot under Linux is to test all the generic code, not specific to any one architecture. The idea is to create unit tests which we can run to test this upper level code.

Sandbox configurations includes:

  • CONFIG_SANDBOX
  • CONFIG_SANDBOX_BIG_ENDIAN

There are two versions of the sandbox:

  • 32-bit-wide integers
  • 64-bit-wide integers.

  Note:by default, the sandbox it built for a 32-bit host. The sandbox using 64-bit-wide integers can only be built on 64-bit hosts.

2.Basic Operation

  To run sandbox U-Boot use something like:

 $make sandbox_defconfig all$./u-boot

Note: If you get errors about ‘sdl-config: Command not found’ you may need to install libsdl1.2-dev or similar to get SDL support. Alternatively you can build sandbox without SDL (i.e. no display/keyboard support) by removing the CONFIG_SANDBOX_SDL line in include/configs/sandbox.h or using:

#Some machines do not have SDL libraries installed, and it is still useful to build sandbox without LCD/keyboard support.
$sudo apt-get install libsdl1.2-dev
$make sandbox_defconfig all NO_SDL=1
$./u-boot
U-Boot will start on your computer, showing a sandbox emulation of the serial
console:
U-Boot 2014.04 (Mar 20 2014 - 19:06:00)
DRAM:  128 MiB
Using default environmentIn:    serial
Out:   lcd
Err:   lcd
=>

  You can issue commands as your would normally. If the command you want is not supported you can add it to include/configs/sandbox.h.

  To exit, type ‘reset’ or press Ctrl-C.

  You can use the test-dm.sh:

  1 #!/bin/sh2 3 die() {4     echo $15     exit 16 }7 8 NUM_CPUS=$(cat /proc/cpuinfo |grep -c processor)9 make O=sandbox sandbox_config  || die "Cannot configure U-Boot"10 make O=sandbox -s -j${NUM_CPUS} || die "Cannot build U-Boot"11 12 dd if=/dev/zero of=spi.bin bs=1M count=213 echo -n "this is a test" > testflash.bin14 dd if=/dev/zero bs=1M count=4 >>testflash.bin17 ./sandbox/u-boot -d sandbox/arch/sandbox/dts/test.dtb -i "dm test"        18 #./sandbox/u-boot -d sandbox/arch/sandbox/dts/test.dtb -c "dm test"                                                                                    19 rm -f spi.bin20 rm -f testflash.bin

Note:
  To execute commands directly, use the -c option. When -c is used, U-Boot exits after the command is complete,but you can force it to go to interactive mode instead with -i.

You can use the command below:

Documents/work/code/u-boot/u-boot$ ./sandbox/u-boot -help
U-Boot 2019.07-rc3-dirty (May 31 2019 - 19:10:05 +0800)u-boot, a command line test interface to U-BootUsage: u-boot [options]
Options:--show_of_platdata         Show of-platdata in SPL-L, --log_level        <arg>   Set log level (0=panic, 7=debug)-v, --verbose                  Show test output-t, --terminal         <arg>   Set terminal to raw/cooked mode-l, --show_lcd                 Show the sandbox LCD display-n, --ignore_missing           Ignore missing state on read-w, --write                    Write state FDT on exit-r, --read                     Read the state FDT on startup-s, --state            <arg>   Specify the sandbox state FDT--rm_memory                Remove memory file after reading-m, --memory           <arg>   Read/write ram_buf memory contents from file-j, --jump             <arg>   Jumped from previous U-Boot-i, --interactive              Enter interactive mode-D, --default_fdt              Use the default u-boot.dtb control FDT in U-Boot directory-d, --fdt              <arg>   Specify U-Boot's control FDT-c, --command          <arg>   Execute U-Boot command-b, --boot                     Run distro boot commands-h, --help                     Display help

2.1.Console / LCD support

  Assuming that CONFIG_SANDBOX_SDL is defined when building, you can run the sandbox with LCD and keyboard emulation, using something like:

./u-boot -d u-boot.dtb -l
Note : -l causes the LCD emulation window to be shown.

  This will start U-Boot with a window showing the contents of the LCD. If that window has the focus then you will be able to type commands as you would on the console. You can adjust display settings in the device tree file - arch/sandbox/dts/sandbox.dts.

3.Supported Drivers

 174U-Boot sandbox supports these emulations:175176- Block devices177- Chrome OS EC178- GPIO179- Host filesystem (access files on the host from within U-Boot)180- I2C181- Keyboard (Chrome OS)182- LCD183- Network184- Serial (for console only)185- Sound (incomplete - see sandbox_sdl_sound_init() for details)186- SPI187- SPI flash188- TPM (Trusted Platform Module)

There are unfortunately quite a few variants at present:

There are unfortunately quite a few variants at present:200201 sandbox - should be used for most tests202 sandbox64 - special build that forces a 64-bit host203 sandbox_flattree - builds with dev_read_...() functions defined as inline.204    We need this build so that we can test those inline functions, and we205    cannot build with both the inline functions and the non-inline functions206    since they are named the same.207 sandbox_noblk - builds without CONFIG_BLK, which means the legacy block208    drivers are used. We cannot use both the legacy and driver-model block209    drivers since they implement the same functions210 sandbox_spl - builds sandbox with SPL support, so you can run spl/u-boot-spl211    and it will start up and then load ./u-boot. It is also possible to212    run ./u-boot directly.

4.Testing

  U-Boot sandbox can be used to run various tests, mostly in the test/ directory. These include:

 401  command_ut402     - Unit tests for command parsing and handling403  compression404     - Unit tests for U-Boot's compression algorithms, useful for405       security checking. It supports gzip, bzip2, lzma and lzo.406  driver model407     - Run this pytest408          ./test/py/test.py --bd sandbox --build -k ut_dm -v409  image410     - Unit tests for images:411          test/image/test-imagetools.sh - multi-file images412          test/image/test-fit.py        - FIT images413  tracing414     - test/trace/test-trace.sh tests the tracing system (see README.trace)415  verified boot416      - See test/vboot/vboot_test.sh for this417

Note: To run all tests use “make check”.

5.Related code about the sandbox:

  • include/configs/sandbox.h
  • arch/sandbox/
  • board/sandbox/
  • test/dm/

参考资料:
https://lxr.missinglinkelectronics.com/uboot/board/sandbox/README.sandbox

Uboot sandbox相关推荐

  1. U-Boot 之三 U-Boot 源码文件解析及移植过程详解

      在之前的博文 Linux 之八 完整嵌入式 Linux 环境介绍及搭建说明 中我们说了要一步步搭建整个嵌入式 Linux 运行环境.我所使用的硬件平台及整个要搭建的嵌入式 Linux 环境见博文 ...

  2. 奇小葩讲设备树(3/5)-- Linux设备树详解(三)u-boot设备树的传递

    前面两节介绍了设备的基本概念.编译.结构的组成,本章讨论的主要内容为 dtb如何通过Bootloader引导程序加载到内核 bootloader如何解析dbt bootloader支持哪些dtb的操作 ...

  3. U-Boot源码目录分析(VScode工程创建及文件夹过滤)

    参考:U-Boot工程目录介绍 作者:一只青木呀 发布时间: 2020-10-21 14:47:30 网址:https://blog.csdn.net/weixin_45309916/article/ ...

  4. MT7621_移植篇(3) uboot编译+配置项分析

    U-Boot("通用引导加载程序",通常简称为U-Boot)是一种开源的主引导加载程序,用于嵌入式设备中打包引导设备操作系统内核的指令.它可用于多种计算机架构,包括68k.ARM. ...

  5. U-Boot 之零 源码文件、启动阶段(TPL、SPL)、FALCON、设备树

      最近,工作重心要从裸机开发转移到嵌入式 Linux 系统开发,在之前的博文 Linux 之八 完整嵌入式 Linux 环境.(交叉)编译工具链.CPU 体系架构.嵌入式系统构建工具 中详细介绍了嵌 ...

  6. arm linux 移植过程——uboot makefile注释

    uboot makefile注释 为什么要注释uboot的Makefile呢?这是一个玄学问题,首先,我本人对make的工作机制比较清楚,但是从来没自己写过Makefile,而且很多语法在配置编译条件 ...

  7. Uboot 板级初始化流程and so on

    -------------------------- 本文以U-boot 2018.09源码 mips mt7621进行举例说明. 此预期的理论初始化流程适用于全U-boot和SPL(Secondar ...

  8. 用 make menuconfig 图形化配置 uboot

    U-Boot图形化配置及其原理 uboot可以通过mx6ull_alientek_emmc_defconfig来配置,或者通过文件mx6ull_alientek_emmc.h来配置:还有一种配置ubo ...

  9. [u-boot 2020.07] README

    挖坑,难填! 摘要: 状态: 在哪里获得帮助: 在哪里获取源代码: 我们来自哪里: 名称和拼写: 版本控制: 目录层次结构: 软件配置: 处理器架构和板类型的选择: 沙盒环境(Sandbox): Bo ...

最新文章

  1. php让十进制输出十六进制(ascill)码
  2. Git 码云 Github
  3. 文本打开方式和二进制打开方式的区别是什么?
  4. 查看某个方法在哪里被调用_一篇文章带你查看并处理Pandas数据
  5. osgi框架和spring区别_BATJ面试必会之 Spring 篇(二)
  6. 看人家如何拿到腾讯阿里的offer
  7. JAVA设置流中当前位置_Java程序来标记此输入流中的当前位置
  8. C语言实现2048小游戏---粤嵌GE6818嵌入式系统实训
  9. python和区块链哪个好_10个最流行的Python区块链开源项目
  10. Cascadea for Mac(强大的CSS编辑器)
  11. 求求你们了,别再写满屏的 if/ else 了!
  12. 仓库货位 mysql_Max(TM)财务进销存管理系统 V1.1.12 MySQL网络版
  13. 程序员必须了解的10大技术搜索引擎
  14. 4.文本分类——textRNN模型
  15. 2015ccpc——G - Ancient Go
  16. 11 个最佳免费安全网站
  17. crh寄存器_STM32 学习笔记(寄存器)---2
  18. CoreDNS 的插件使用说明
  19. excel 画散点图 怎么设置图片的分辨率_双代号时标网络图用Excel画
  20. SpringBoot实现音乐网站解析(支持腾讯、网易、小米、酷狗)

热门文章

  1. 分析现行的常用的文件格式类别
  2. EyouCMS,基于thinkphp5+小程序+layui研发的入门级CMS
  3. 交叉连接(CROSS JOIN)
  4. Maven学习(三) -- 仓库(转自--江湖小妞)
  5. VLAN端口属性详解
  6. Django文件部署(3.涉及到的vim指令必须提一下)(全)
  7. python秒懂百科视频_百度百科上线“秒懂”视频功能 用短视频呈现词条内容
  8. JAVA整合阿里云ONS(RocketMQ)
  9. Java类变量和实例变量
  10. 谈谈我在大学期间的一些计算机选修课