• 学习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. git学习(持续踩坑中
  2. 中文分词算法python代码_python实现中文分词FMM算法实例
  3. ubuntu 14.04中文显示乱码问题
  4. 李飞飞:阿里云数据库已做好全面服务政企市场的准备
  5. 中兴高调秀Axon 10 Pro 5G版20倍变焦样张:号称媲美万元广角镜头
  6. 作业帮:字符串反转(头部插入)
  7. [转] Java内部类详解
  8. 物联网平台发展前景如何快速发展
  9. C# 词法分析器(四)构造 NFA
  10. linux中vim怎么编辑文件内容,Linux 使用vim命令编辑文件内容
  11. android 抓包与防抓包设置
  12. UVA - 10400 Game Show Math
  13. 手机微信和QQ接收到的文件路径
  14. Processing绘制星空-1-随机生成静态星星
  15. 相对比性能稳定速度快的香港服务器有哪些
  16. 一次手机木马的清除记录(手机刷机)
  17. GBase 8a的产品简介
  18. [讨论]去掉office正版提醒
  19. 如何获取足球【赛程赛果】数据
  20. 基础连接已经关闭: 接收时发生意外错误

热门文章

  1. 关于MFCC的一些笔记(python)
  2. python简单的输出星期几
  3. 章10 外国语言测试
  4. 在微信小程序中如何使用wx.onLocationChange()【转载】
  5. 数据结构 - JS实现二叉树
  6. 北京尚学堂python 百度网盘_北京尚学堂_1903期_Python_全套视频教程(视频、源码、课件)...
  7. Java 格林威治时间字符串格式化
  8. 如何使用JW Player来播放Flash并隐藏控制按钮和自定义播放完成后执行的JS
  9. 两个excel有两列不完全相同的数据,以它们为匹配ID,使一个excel中的数据转移到另外一个excel中
  10. Quick RF Tips for General Reference