- V3s (Lichee Pi Zero)
- H3 (Orange Pi PC)
- H5 (Orange Pi PC2)
- H616 (Orange Pi Zero2)
- H6 (Orange Pi One Plus)
- R40/A40/V40 (Banana Pi BPI-M2 Berry)
- T113-S3 (MangoPi MQ-R)
IAR allows out-of-the-box execution of debuggee code in SUNXI SRAM by selecting the proper core and using a compatible linker configuration. To run code in DRAM, it must be initialized first.
This package enables step-by-step debugging in DRAM using J-Link or a compatible JTAG emulator. It was done by porting the U-Boot clock and DRAM initialization code into an IAR macro called sunxi.mac. Initialization by executing precompiled binary is also supported.
- Setup IAR 9.40 (for Cortex-A7 only), 9.50 and later (for both A7 and A53), J-Link, board, USB dongle (optional)
- Clone repo:
git clone --recurse-submodules https://github.com/grinux/sunxi-jtag.git - Open
sunxi-jtag.ewporsunxi-jtag-94.ewpfor EWARM 9.40 - In
sunxi_jtag.hchangeCFG_SYS_UARTto desired console UART - Build
XX-dram-apptarget - For Cortex-A53 core (H5, etc.) run J-Link GDB server GUI and select Cortex-A53 core, JTAG interface, and GDB port 2331
- Or run console version with params:
-select USB=0 -device Cortex-A53 -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile -port 2331
- Or run console version with params:
- Start debugging. If IAR asks for memory configuration, click "Use factory" button
- If message box appears, select desired initialization mode and set it permanently in project options following the message box instructions
- Run
- If the USB dongle is connected, "Hello from DRAM" output appears
- Edit linker configuration
sunxi.icfto set desired code/DRAM area size - Enjoy running applications from DRAM without unwanted tricks
The project allows running the original U-Boot initialization code. Therefore, sunxi.mac has two working modes available to select on first load:
-
Macro initialization (supports V3s, H3, R40 only)
- Initialization is performed by JTAG directly accessing necessary registers, then the main debuggee is loaded
-
Binary initialization
- Initialization executable is loaded by JTAG → executed → results evaluated → main debuggee loaded
Performance between the two modes is negligible.
To use binary mode:
- Select a suitable
XX-dram-inittarget (e.g.,V3s-dram-init,H3-dram-init) - In
sunxi_jtag.hsetCFG_SYS_INIT_DEBUGto1to enable console output for dram-init target - Build. File
sunXX-YY-dram-init.hexwill be generated - Debug if needed
- Change the target back to
XX-dram-app - In Options → Debugger → Extra Options add or change:
--macro_param init_mode="bin"- This tells
sunxi.macto go into binary mode and load and run the generated hex file before the main debuggee
- This tells
- Start debugging
- Check the debug log to verify hex file was loaded and executed properly
- Enjoy
If you have any trouble, please open an issue here or submit a pull request.
GPL-2.0 license inherited from U-Boot. Checkout this statement about using in proprietary projects.