Heinrich Schuchardt | 3969b32 | 2023-06-25 13:40:23 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: loads (command) |
| 5 | |
Heinrich Schuchardt | 3969b32 | 2023-06-25 13:40:23 +0200 | [diff] [blame] | 6 | loads command |
| 7 | ============= |
| 8 | |
| 9 | Synopsis |
| 10 | -------- |
| 11 | |
| 12 | :: |
| 13 | |
| 14 | loads [offset [baud]] |
| 15 | |
| 16 | Description |
| 17 | ----------- |
| 18 | |
| 19 | The loads command is used to transfer a file to the device via the serial line |
| 20 | using the Motorola S-record file format. |
| 21 | |
| 22 | offset |
| 23 | offset added to the addresses in the S-record file |
| 24 | |
| 25 | baud |
| 26 | baud rate to use for download. This parameter is only available if |
| 27 | CONFIG_SYS_LOADS_BAUD_CHANGE=y |
| 28 | |
| 29 | Example |
| 30 | ------- |
| 31 | |
| 32 | As example file to be transferred we use a script printing 'hello s-record'. |
| 33 | Here are the commands to create the S-record file: |
| 34 | |
| 35 | .. code-block:: bash |
| 36 | |
| 37 | $ echo 'echo hello s-record' > script.txt |
| 38 | $ mkimage -T script -d script.txt script.scr |
| 39 | Image Name: |
| 40 | Created: Sun Jun 25 10:35:02 2023 |
| 41 | Image Type: PowerPC Linux Script (gzip compressed) |
| 42 | Data Size: 28 Bytes = 0.03 KiB = 0.00 MiB |
| 43 | Load Address: 00000000 |
| 44 | Entry Point: 00000000 |
| 45 | Contents: |
| 46 | Image 0: 20 Bytes = 0.02 KiB = 0.00 MiB |
| 47 | $ srec_cat script.scr -binary -CRLF -Output script.srec |
| 48 | $ echo -e "S9030000FC\r" >> script.srec |
| 49 | $ cat script.srec |
| 50 | S0220000687474703A2F2F737265636F72642E736F75726365666F7267652E6E65742F1D |
| 51 | S1230000270519566D773EB6649815E30000001700000000000000003DE3D97005070601E2 |
| 52 | S12300200000000000000000000000000000000000000000000000000000000000000000BC |
| 53 | S11A00400000000F0000000068656C6C6F20732D7265636F72640A39 |
| 54 | S5030003F9 |
| 55 | S9030000FC |
| 56 | $ |
| 57 | |
| 58 | The load address in the first S1 record is 0x0000. |
| 59 | |
| 60 | The terminal emulation program picocom is invoked with *cat* as the send |
| 61 | command to transfer the file. |
| 62 | |
| 63 | .. code-block:: |
| 64 | |
| 65 | picocom --send-cmd 'cat' --baud 115200 /dev/ttyUSB0 |
| 66 | |
| 67 | After entering the *loads* command the key sequence <CTRL-A><CTRL-S> is used to |
| 68 | let picocom prompt for the file name. Picocom invokes the program *cat* for the |
| 69 | file transfer. The loaded script is executed using the *source* command. |
| 70 | |
| 71 | .. code-block:: |
| 72 | |
| 73 | => loads $scriptaddr |
| 74 | ## Ready for S-Record download ... |
| 75 | |
| 76 | *** file: script.srec |
| 77 | $ cat script.srec |
| 78 | |
| 79 | *** exit status: 0 *** |
| 80 | |
| 81 | ## First Load Addr = 0x4FC00000 |
| 82 | ## Last Load Addr = 0x4FC0005B |
| 83 | ## Total Size = 0x0000005C = 92 Bytes |
| 84 | ## Start Addr = 0x00000000 |
| 85 | => source $scriptaddr |
| 86 | ## Executing script at 4fc00000 |
| 87 | hello s-record |
| 88 | => |
| 89 | |
| 90 | Configuration |
| 91 | ------------- |
| 92 | |
| 93 | The command is only available if CONFIG_CMD_LOADS=y. The parameter to set the |
| 94 | baud rate is only available if CONFIG_SYS_LOADS_BAUD_CHANGE=y |
| 95 | |
| 96 | Return value |
| 97 | ------------ |
| 98 | |
| 99 | The return value $? is 0 (true) on success, 1 (false) otherwise. |