Updating Ben NanoNote software
Contents |
The NAND
- Has pages that are 4096 bytes in length
- Has blocks that are 128 pages in length
- Has 4096 blocks
- 4096 × 128 × 4096 = 2147483648 ( 2 GB)
To find out which version of the rootfs you have:
nanonote$ cat /etc/VERSION
xburst-tools
Installing xburst-tools
The xburst-tools package gives these commands:
- usbboot
- xbboot
The wget URLs below might not be the latest. Use the latest from here
For Debian-based distributions
$ cd /tmp/ $ wget http://projects.qi-hardware.com/media/upload/xburst-tools/files/xburst-tools_0.0+201004-0.1_i386.deb $ sudo apt-get install --no-install-recommends libconfuse0 $ sudo dpkg -i xburst-tools_0.0+201004-0.1_i386.deb $ dpkg -L xburst-tools | grep bin/ /usr/bin/usbboot /usr/bin/xbboot
To install a tarball
Ensure that the confuse library is installed.
$ cd /tmp/ $ wget http://projects.qi-hardware.com/media/upload/xburst-tools/files/xburst-tools_0.0+201002-1_i386.bin.tar.bz2 $ sudo tar jxvf xburst-tools_0.0+201002-1_i386.bin.tar.bz2 -C /
usbboot
- usbboot [options] ... (must run as root)
-h --help Print this help message -v --version Print the version number -c --command Direct run the commands, split by ';' -f --configure configure file path <run without options to enter commands via usbboot prompt>
sub-command:
- boot
before run nprog and nerase. we should upload xburst_stage1 and xburst_stage2 to device.
- nprog (1) (2) (3) (4) (5)
(1) start page number
(2) image file name
(3) device index number
(4) flash index number
(5) image type must be:
-n: no oob
-o: with oob no ecc
-e: with oob and ecc
- nerase (1) (2) (3) (4)
(1) start block number (2) block length (3) device index number (4) flash chip index number
usbboot.cfg
usbboot.cfg will installed to /etc/xburst-tools/
[PLL]
EXTCLK = 12 #Define the external crystal in MHz CPUSPEED = 252 #Define the PLL output frequency PHMDIV = 3 #Define the frequency divider ratio of PLL=CCLK:PCLK=HCLK=MCLK BOUDRATE = 57600 #Define the uart boudrate USEUART = 0 #Use which uart, 0/1 for jz4740,0/1/2/3 for jz4750
[SDRAM]
BUSWIDTH = 16 #The bus width of the SDRAM in bits (16|32) BANKS = 4 #The bank number (2|4) ROWADDR = 13 #Row address width in bits (11-13) COLADDR = 9 #Column address width in bits (8-12) ISMOBILE = 0 #Define whether SDRAM is mobile SDRAM, this only valid for Jz4750 ,1:yes 0:no ISBUSSHARE = 1 #Define whether SDRAM bus share with NAND 1:shared 0:unshared DEBUGOPS = 0
[NAND]
NAND_BUSWIDTH = 8 #The width of the NAND flash chip in bits (8|16|32) NAND_ROWCYCLES = 3 #The row address cycles (2|3) NAND_PAGESIZE = 4096 #The page size of the NAND chip in bytes(512|2048|4096) NAND_PAGEPERBLOCK = 128 #The page number per block NAND_FORCEERASE = 1 #The force to erase flag (0|1) NAND_OOBSIZE = 128 #oob size in byte NAND_ECCPOS = 12 #Specify the ECC offset inside the oob data (0-[oobsize-1]) NAND_BADBLOCKPOS = 0 #Specify the badblock flag offset inside the oob (0-[oobsize-1]) NAND_BADBLOCKPAGE = 127 #Specify the page number of badblock flag inside a block(0-[PAGEPERBLOCK-1]) NAND_PLANENUM = 1 #The planes number of target nand flash NAND_BCHBIT = 4 #Specify the hardware BCH algorithm for 4750 (4|8) NAND_WPPIN = 0 #Specify the write protect pin number NAND_BLOCKPERCHIP = 0 #Specify the block number per chip,0 means ignore
Example
- Erase the whole nand with the command:
$ sudo usbboot -c "boot;nerase 0 4096 0 0"
- Reflash just the u-boot:
$ sudo usbboot -c "boot;nprog 0 openwrt-xburst-u-boot.bin 0 0 -n"
- Reflash just the kernel partition with
$ sudo usbboot -c "boot;nprog 1024 openwrt-xburst-uImage 0 0 -n"
- Reflash just the rootfs partition with
$ sudo usbboot -c "boot;nprog 2048 openwrt-xburst-qi_lb60.ubi 0 0 -n"
xbboot
xbboot [vendor_request] ... (must run as root)
-h --help print this help message -v --version print the version number [-u | --upload] <address> <path> upload file at <path> to <address> then jump to <address>
bulk_read <len> read len bulk bytes from USB, write to stdout bulk_write <path> write file at <path> to USB [get_info | VR_GET_CPU_INFO] read 8-byte CPU info and write to stdout [set_addr | VR_SET_DATA_ADDRESS] <addr> send memory address [set_len | VR_SET_DATA_LENGTH] <len> send data length [flush_cache | VR_FLUSH_CACHES] flush I-Cache and D-Cache [start1 | VR_PROGRAM_START1] <addr> transfer data from D-Cache to I-Cache and branch to I-Cache [start2 | VR_PROGRAM_START2] <addr> branch to <addr> directly
-u will upload the /usr/share/xburst-tools/stage1 to nanonote. then run the stage1. it will init gpio, serial, pll, sdram, nand. then xbboot will load the <path> file to sdram at <address> then jump to <address>. for example:
sudo xbboot -u 0x80600000 /PATH/TO/zImage.bin
will upload kernel zImage to NanoNote 0x80600000. then run the zImage.
-u can be expressed as series vendor_request like:
#!/bin/bash xbboot set_addr 0x80002000 xbboot bulk_write /usr/share/xburst-tools/stage1.bin xbboot start1 0x80002000 xbboot get_info xbboot flush_cache xbboot set_addr 0x80600000 xbboot bulk_write /PATH/TO/zImage.bin xbboot flush_cache xbboot start2 0x80600000
since the 0x80002000 is the D-Cache address. so we upload the stage1.bin to 0x80002000.
How to reflash
|
DO NOT USE A USB HUB. Make sure your NanoNote is directly connected to a Linux PC |
|
DO NOT USE LINUX VIRTUAL MACHINE running in your Windows or MacOS pc |
Get the reflash_ben.sh script and make it executable (you only need to do this once per system you want to reflash from, unless the reflash script changes) via the following commands:
$ wget http://downloads.qi-hardware.com/software/images/Ben_NanoNote_2GB_NAND/reflash_ben.sh $ chmod +x reflash_ben.sh
Boot your NanoNote into USB BOOT mode. As soon as lsusb (on your Linux PC) lists a new device, run reflash_ben.sh. This will download some pre-built images and (re)flash the NanoNote.
$ sudo ./reflash_ben.sh
Afterwards, reboot your NanoNote. First, you will see
- preinit - Press CTRL-C for failsafe
After a while, you will see Please press Enter to activate this console. on the console of your NanoNote.
Alternative to using the reflash_ben.sh script
Situation
I had tried to use the reflash script a number of times without a lot of success. I found myself having to run "reflash_ben.sh -b" to install the boot, then "reflash_ben.sh -k" to install the kernel, separately. One day even that didn't work.
Solution
Before beginning the following steps, ensure that you've downloaded the latest files into a working directory and that you execute the commands from that directory
- Take the battery out, unplug the USB cable, keep your NanoNote totally disconnected for a minute or so
- Use the carbonized rubber button to connect the usb boot pins in the battery compartment
- On your Linux machine, run 'watch lsusb'.
- Short the USB boot pins, connect the USB cable (don't use a hub)
- The numbers 601a:4740 should show up. if not, press the power button (still holding the USB boot pins closed/shorting)
- Now, from the working directory on the host, run 'usbboot'
- Next, type "boot"
- Then "nerase 0 4096 0 0" This will erase your device. you only need to do this once
- Next, we will flash u-boot Run "nprog 0 openwrt-xburst-u-boot.bin 0 0 -n" (u-boot goes to page 0, Linux kernel to page 1024, rootfs to page 2048)
- Next, we will flash the kernel Run "nprog 1024 openwrt-xburst-uImage.bin 0 0 -n"
- Finally, the rootfs Run "nprog 2048 openwrt-xburst-qi_lb60-root.ubi 0 0 -n" This will take a while, up to 15 minutes. As it is working, you will see usbboot's loooong output scrolling down, some numbers slowly increasing.
Notes
Usbboot is not very robust. Neither on the side of the code that is running on the NanoNote, nor how it implements the USB protocol, nor on how it handles NAND. It's much better to let the Linux kernel do this. Unless there is a real new feature in u-boot, leave u-boot unchanged on your NanoNote now
Future Options
In the future, instead of following these instructions, you could buy a microSD card and try these steps.
- When a new kernel+rootfs comes out, flash it onto a microSD card, 2 partitions: partition1 = vfat = uImage, partition2 = ext2 = rootfs
- Then turn on your NanoNote, press 'm' to tell u-boot to boot from the microSD card. You only need a functioning u-boot in NAND for this to work. It will take the Linux kernel + rootfs from the microSD
You first boot from microSD, and you have the uImage.bin and .ubi files on the microSD. Then you use one of the several Linux NAND tools (I always use ubiformat but some people say mtd is better).
Known Errors
Error - no XBurst device found
- this means usbboot cannot find an xburst device (eg. the Ben NanoNote) attached to usb
- disconnect your device
- restart the device in usbboot mode and check with 'lsusb' if you can find the device
Uninstalling xburst-tools
For Debian-based distributions:
$ sudo aptitude remove xburst-tools
If installed from a tarball:
$ sudo rm -f /usr/local/bin/usbboot $ sudo rm -f /usr/local/man/man1/usbboot.1.gz $ sudo rm -f /usr/local/bin/xbboot $ sudo rm -f /usr/local/man/man1/xbboot.1.gz $ sudo rm -rf /usr/local/etc/xburst-tools/ $ sudo rm -rf /usr/local/share/xburst-tools/