Kernel Flashing supplement
From BUG Wiki
Contents |
Upgrading a Kernel via Handylink Serial Connection (requires serial to handylink)
Overview
The BUG stores the GNU/Linux kernel in onboard flash memory. The remainder of the user root-filesystem exists on the MMC or SD card provided with the BUG. BUG uses Redboot as the boot manager. To upgrade your kernel in the case of boot failure, the steps below outline how to flash the kernel via a custom serial/handylink cable. For more information about this cable see Handylink to DB9, or contact BUG+Care. It is very important that the instructions below are followed exactly. If you accidentally overwrite Redboot, for example, the only solution is to use a BDI and JTAG to reimage the flash component on the board. This is a very time-consuming process and is typically only done that the factory if necessary.
Requirements
- You need minicom (or kermit) and lrzsz on host system.
sudo apt-get install lrzsz minicom
- Download the kernel from BugLabs download site. Most recent at the time of writing this is R1.3.
Delete the old Kernel (if necessary)
- Boot the BUG and ctrl-c to drop into Redboot
Running boot script in 1.000 seconds - enter ^C to abort ^C (ctl-c)
- List the flash partition table to determine the kernel name: fis list
BUG_RedBoot> fis list Name FLASH addr Mem addr Length Entry point RedBoot 0xA0000000 0xA0000000 0x00040000 0x00000000 kernel 0xA1000000 0x00100000 0x00210000 0x00100000 FIS directory 0xA1FFC000 0xA1FFC000 0x00003000 0x00000000 RedBoot config 0xA1FFF000 0xA1FFF000 0x00001000 0x00000000
BUG_RedBoot> fis delete kernel Delete image 'kernel' - continue (y/n)? y flash_erase(): addr = a0100000, len = 200000 flash_erase(): end_addr = a0300000, block = a0100000 flash_erase(): end_addr = a0300000, block = a0100000 ... Erase from 0xa0100000-0xa0300000: flash_erase(): block = a0100000, block_size = 4000
Send the Kernel
- Tell Redboot to expect a kernel via ymodem and load it ram: load -b 0x100000 -m ymodem -v -r
BUG_RedBoot> load -b 0x100000 -m ymodem -v -r CC...
- Send the Kernel via ymodem in minicom, the key-combination to do this is Ctrl+A then Z, then S, then navigate to the zImage file you downloaded above using the arrow keys and spacebar to get in a folder , tag the file (space) and hit Enter for Okay. You'll see progress in the line Ymodem sectors/kbytes sent, and final output should look like this:
+-----------[ymodem upload - Press CTRL-C to quit]------------+ |Retry 0: NAK on sector | |Bytes Sent:1621120 BPS:7560 | |Sending: | |Ymodem sectors/kbytes sent: 0/ 0k | |Transfer complete | | | | READY: press any key to continue... | +-------------------------------------------------------------+
CRaw file loaded 0x00100000-0x0028bc27, assumed entry at 0x00100000 xyzModem - CRC mode, 12667(SOH)/0(STX)/0(CAN) packets, 6 retries
Write Kernel to Flash
- After loading the kernel into memory, you'll need to write it to flash. See below.
- List the flash partition table: fis list
BUG_RedBoot> fis list Name FLASH addr Mem addr Length Entry point RedBoot 0xA0000000 0xA0000000 0x00040000 0x00000000 FIS directory 0xA1FFC000 0xA1FFC000 0x00003000 0x00000000 RedBoot config 0xA1FFF000 0xA1FFF000 0x00001000 0x00000000
BUG_RedBoot> fis unlock -f 0xa0100000 -l 0x200000
BUG_RedBoot> fis create -b 0x100000 -l 0x200000 -f 0xa0100000 kernel ...
Configure Boot Script
- You will want to ensure that Redboot is configured to load your kernel image. Use fconfig to see the boot script. Type fconfig, hit enter, hit enter when asked Run script at boot: true, hit enter again.
BUG_RedBoot> fconfig Run script at boot: true Boot script: .. clock 532 .. fis load kernel -b 0x100000 .. exec -b 0x100000 -l 0x200000 -c "noinitrd console=ttymxc4,115200 rootdelay=1 init=/linuxrc root=/dev/mmcblk0p1 ip=192.168.0.111:192.168.0.121:192.168.0.121:255.255.255.0:BUG::off mem=128M jtag=on" Enter script, terminate with empty line >>
- In this case, the boot script is configured to load the kernel image called kernel into memory address 0x100000, as determined by the second line. If yours says "image2" or something else, you'll want to enter:
>> clock 532 >> fis load kernel -b 0x100000 >> exec -b 0x100000 -l 0x200000 -c "noinitrd console=ttymxc4,115200 rootdelay=1 init=/linuxrc root=/dev/mmcblk0p1 ip=192.168.0.111:192.168.0.121:192.168.0.121:255.255.255.0:BUG::off mem=128M jtag=on"
- Hit enter twice to indicate the end of the boot script. There is output to further configure the boot process. You'll want to keep these the same by hitting enter at each but the very last
Update RedBoot non-volatile configuration - continue (y/n)? y. The default is n, or no, and the changes will not be saved unless you respond y, for yes.
>> Boot script timeout (1000ms resolution): 1 Use BOOTP for network configuration: false Gateway IP address: 192.169.0.1 Local IP address: 192.169.0.2 Local IP address mask: 255.255.255.0 Default server IP address: 192.169.0.1 Board specifics: 0 Console baud rate: 115200 Set eth0 network hardware address [MAC]: true eth0 network hardware address [MAC]: 0x00:0x50:0xC2:0x69:0xC0:0x18 GDB connection port: 9000 Force console for special debug messages: false Network debug at boot time: false Update RedBoot non-volatile configuration - continue (y/n)? y
- Reset the BUG to test your changes.
BUG_RedBoot>reset
