| 188 | |
| 189 | = RTEMS Libbsd Debugger Application = |
| 190 | |
| 191 | The RTEMS Libbsd package builds an RTEMS Debugger application. This test application lets you connect to the running RTEMS application using GDB. |
| 192 | |
| 193 | You can find the application in the `rtems-libbsd` build tree: |
| 194 | |
| 195 | {{{ |
| 196 | $ ls -las build/arm-rtems4.12-xilinx_zynq_zedboard/debugger01.exe |
| 197 | 19745 -rwxr-xr-x 1 chris user 20171796 Dec 23 14:39 build/arm-rtems4.12-xilinx_zynq_zedboard/debugger01.exe |
| 198 | }}} |
| 199 | |
| 200 | Convert this executable to the U-Boot image format using the script above and copy to the TFTP server then boot the board: |
| 201 | |
| 202 | {{{ |
| 203 | U-Boot SPL 2016.05-00598-gb2f1858-dirty (Jun 04 2016 - 15:32:53) |
| 204 | mmc boot |
| 205 | Trying to boot from MMC1 |
| 206 | reading system.dtb |
| 207 | reading uImage |
| 208 | spl_load_image_fat: error reading image uImage, err - -1 |
| 209 | reading u-boot.img |
| 210 | reading u-boot.img |
| 211 | |
| 212 | |
| 213 | U-Boot 2016.05-00598-gb2f1858-dirty (Aug 05 2016 - 08:30:10 +1000) |
| 214 | |
| 215 | Model: Zynq MicroZED Board |
| 216 | Board: Xilinx Zynq |
| 217 | DRAM: ECC disabled 1 GiB |
| 218 | MMC: sdhci@e0100000: 0 |
| 219 | SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB |
| 220 | *** Warning - bad CRC, using default environment |
| 221 | |
| 222 | In: serial@e0001000 |
| 223 | Out: serial@e0001000 |
| 224 | Err: serial@e0001000 |
| 225 | Model: Zynq MicroZED Board |
| 226 | Board: Xilinx Zynq |
| 227 | Net: ZYNQ GEM: e000b000, phyaddr 0, interface rgmii-id |
| 228 | |
| 229 | Warning: ethernet@e000b000 (eth0) using random MAC address - fa:69:35:9e:04:2f |
| 230 | eth0: ethernet@e000b000 |
| 231 | reading uEnv.txt |
| 232 | 162 bytes read in 10 ms (15.6 KiB/s) |
| 233 | Importing environment from mmc ... |
| 234 | Checking if uenvcmd is set ... |
| 235 | Running uenvcmd ... |
| 236 | Booting RTEMS XxX from net |
| 237 | ethernet@e000b000 Waiting for PHY auto negotiation to complete...... done |
| 238 | BOOTP broadcast 1 |
| 239 | BOOTP broadcast 2 |
| 240 | DHCP client bound to address 10.10.5.247 (257 ms) |
| 241 | Using ethernet@e000b000 device |
| 242 | TFTP from server 10.10.5.1; our IP address is 10.10.5.247 |
| 243 | Filename 'zed/rtems.img'. |
| 244 | Load address: 0x2000000 |
| 245 | Loading: ################################################################# |
| 246 | ## |
| 247 | 9 MiB/s |
| 248 | done |
| 249 | Bytes transferred = 976253 (ee57d hex) |
| 250 | ## Booting kernel from Legacy Image at 02000000 ... |
| 251 | Image Name: RTEMS |
| 252 | Image Type: ARM RTEMS Kernel Image (gzip compressed) |
| 253 | Data Size: 976189 Bytes = 953.3 KiB |
| 254 | Load Address: 00104000 |
| 255 | Entry Point: 00104000 |
| 256 | Verifying Checksum ... OK |
| 257 | Uncompressing Kernel Image ... OK |
| 258 | ## Transferring control to RTEMS (at address 00104000) ... |
| 259 | *** LIBBSD DEBUGGER 1 TEST *** |
| 260 | |
| 261 | RTEMS Shell on /dev/console. Use 'help' to list commands. |
| 262 | [/] # nexus0: <RTEMS Nexus device> |
| 263 | cgem0: <Cadence CGEM Gigabit Ethernet Interface> on nexus0 |
| 264 | miibus0: <MII bus> on cgem0 |
| 265 | e1000phy0: <Marvell 88E1512 Gigabit PHY> PHY 0 on miibus0 |
| 266 | e1000phy0: none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto |
| 267 | cgem0: Ethernet address: fa:69:35:9e:04:2f |
| 268 | zy7_slcr0: <Zynq-7000 slcr block> on nexus0 |
| 269 | notice: cgem0: link state changed to DOWN |
| 270 | add host 10.10.5.1: gateway cgem0 |
| 271 | add net default: gateway 10.10.5.1 |
| 272 | rtems-db: remote running |
| 273 | rtems-db: tcp remote: listing on port: 1122 |
| 274 | notice: cgem0: link state changed to UP |
| 275 | }}} |
| 276 | |
| 277 | The U-Boot DHCP address may not be the RTEMS IP address. In my case I have a static IP configured in LibBSD: |
| 278 | |
| 279 | {{{ |
| 280 | [/] # cat /etc/rc.conf |
| 281 | cat /etc/rc.conf |
| 282 | cat: /etc/rc.conf: No such file or directory |
| 283 | [/] # ifconfig |
| 284 | ifconfig |
| 285 | cgem0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 |
| 286 | options=80008<VLAN_MTU,LINKSTATE> |
| 287 | ether fa:69:35:9e:04:2f |
| 288 | inet 10.10.5.15 netmask 0xffffff00 broadcast 10.10.5.255 |
| 289 | inet6 fe80::f869:35ff:fe9e:42f%cgem0 prefixlen 64 scopeid 0x1 |
| 290 | nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> |
| 291 | media: Ethernet autoselect (1000baseT <full-duplex>) |
| 292 | status: active |
| 293 | lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 |
| 294 | options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6> |
| 295 | inet 127.0.0.1 netmask 0xffffff00 |
| 296 | inet6 ::1 prefixlen 128 |
| 297 | inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 |
| 298 | nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> |
| 299 | }}} |
| 300 | |
| 301 | The `ifconfig` command shows the IP address is `10.10.5.15`. We can use this to connect GDB. On the development host run GDB using: |
| 302 | |
| 303 | {{{ |
| 304 | $ arm-rtems4.12-gdb -nx build/arm-rtems4.12-xilinx_zynq_zedboard/debugger01.exe |
| 305 | GNU gdb (GDB) 7.12 |
| 306 | Copyright (C) 2016 Free Software Foundation, Inc. |
| 307 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> |
| 308 | This is free software: you are free to change and redistribute it. |
| 309 | There is NO WARRANTY, to the extent permitted by law. Type "show copying" |
| 310 | and "show warranty" for details. |
| 311 | This GDB was configured as "--host=x86_64-freebsd10.3 --target=arm-rtems4.12". |
| 312 | Type "show configuration" for configuration details. |
| 313 | For bug reporting instructions, please see: |
| 314 | <http://www.gnu.org/software/gdb/bugs/>. |
| 315 | Find the GDB manual and other documentation resources online at: |
| 316 | <http://www.gnu.org/software/gdb/documentation/>. |
| 317 | For help, type "help". |
| 318 | Type "apropos word" to search for commands related to "word"... |
| 319 | Reading symbols from build/arm-rtems4.12-xilinx_zynq_zedboard/debugger01.exe...done. |
| 320 | (gdb) target remote 10.10.5.15:1122 |
| 321 | Remote debugging using 10.10.5.15:1122 |
| 322 | _Thread_Priority_update (queue_context=0x2866c0) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/score/src/threadchangepriority.c:344 |
| 323 | 344 n = queue_context->Priority.update_count; |
| 324 | (gdb) info thread |
| 325 | Id Target Id Frame |
| 326 | * 1 Thread 1.167837697 (UI1 (0a010001), priority(c:254 r:254), stack(s: 32768 a:0x429448), state(DELAY SUSP Wisig)) _Thread_Priority_update (queue_context=0x2866c0) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/score/src/threadchangepriority.c:344 |
| 327 | 2 Thread 1.167837698 (SHLL (0a010002), priority(c: 1 r: 1), stack(s: 32768 a:0x431c08), state(SUSP)) _Thread_Priority_update (queue_context=0x2866c0) at /opt/work/chris/rtems/kernel/rtems.git/c/src/../../cpukit/score/src/threadchangepriority.c:344 |
| 328 | (gdb) kill |
| 329 | Kill the program being debugged? (y or n) y |
| 330 | (gdb) q |
| 331 | }}} |
| 332 | |
| 333 | '''Note:''' |
| 334 | 1. The `-nx` is being used to stop loading any `.gdbinit` files. This done when testing the GDB connection. For a real development environment you should create a suitable `.gdbinit` file. |
| 335 | 2. The remote port on the RTEMS target is `1122`. You can configure this in the RTEMS application. |
| 336 | 3. Killing the session using the `kill` command reboots the target. If you have updated the executable on the TFTP before running this command a new version of the application will be download. |