http://wiki.emacinc.com/wiki/Mounting_JFFS2_Images_on_a_Linux_PC
#!/bin/bash
## Script to mount jffs2 filesystem using mtd kernel modules.
## EMAC, Inc. 2011
if [[ $# -lt 2 ]]
then
echo "Usage: $0 FSNAME.JFFS2 MOUNTPOINT [ERASEBLOCK_SIZE]"
exit 1
fi
if [ "$(whoami)" != "root" ]
then
echo "$0 must be run as root!"
exit 1
fi
if [[ ! -e $1 ]]
then
echo "$1 does not exist"
exit 1
fi
if [[ ! -d $2 ]]
then
echo "$2 is not a valid mount point"
exit 1
fi
if [[ "$3" == "" ]]
then
esize="128"
else
esize="$3"
fi
# cleanup if necessary
umount /tmp/mtdblock0 &>/dev/null
umount $2 &>/dev/null
modprobe -r jffs2 &>/dev/null
modprobe -r block2mtd &>/dev/null
modprobe -r mtdblock &>/dev/null
sleep 0.25
losetup -d /dev/loop1 &>/dev/null
sleep 0.25
modprobe loop || exit 1
losetup /dev/loop1 "$1" || exit 1
modprobe block2mtd || exit 1
modprobe jffs2 || exit 1
if [[ ! -e /tmp/mtdblock0 ]]
then
mknod /tmp/mtdblock0 b 31 0 || exit 1
fi
echo "/dev/loop1,${esize}KiB" > /sys/module/block2mtd/parameters/block2mtd
mount -t jffs2 /tmp/mtdblock0 "$2" || exit 1
echo "Successfully mounted $1 on $2"
exit 0
sudo ./mountfs.sh rootfs.bin rootfs 64
dd if=Nano_flash_480272.bin of=rootfs.img bs=1k skip=5184 status=progress
skip(blocks) = SPI_Flash_RootFS_Offset / blocksize = 0x510000 (byte) / 1024 (byte) = 5184
Duplicate the entire rootfs using tar:
# Mount the JFFS2
sudo ./mountfs.sh rootfs.suniv-f1c100s-musbbin rootfs 64
cd rootfs
tar cvzf ../rootfs.tar.gz .
cd ..
mkdir rootfs_new
cd rootfs_new
tar xvpzf ../rootfs.tar.gz
mkfs.jffs2 -s 256b --pad=0xAF0000 -d rootfs_new/ -o rootfs_new.img
sudo ./sunxi-fel -p spiflash-write 0x0510000 rootfs_new.img
Write the content of rootfs_new.img to 0x0510000 and show progress
sudo sunxi-tools/sunxi-fel -p spiflash-write 0x0100000 linux/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dtb
sudo sunxi-tools/sunxi-fel -p spiflash-write 0x0110000 linux/arch/arm/boot/zImage
sf probe 0;sf erase 0 0x100000;reset
sudo ./sunxi-fel -p -v uboot ~/licheepinano/uboot.bin \
write 0x80008000 ../linux/arch/arm/boot/zImage \
write 0x80C00000 ../linux/arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dtb
bootm 0x80008000 - 0x80C00000
make ARCH=arm menuconfig #add bluethooth, etc.
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j16
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j16 INSTALL_MOD_PATH=out modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j16 INSTALL_MOD_PATH=out modules_install
https://whycan.cn/t_1672.html I'm using Icenowy's 4.15 kernel
- Device Drivers > USB support > MUSB Mode Selection = Host only mode
- Device Drivers > USB support > USB Gadget Support ==> Clear this (Optional, to save some space)
- Edit:
--- ../linux/drivers/clk/sunxi-ng/ccu-suniv.c 2019-01-15 22:48:18.824587965 +0800
+++ drivers/clk/sunxi-ng/ccu-suniv.c 2019-01-23 09:05:17.959348454 +0800
@@ -238,7 +238,7 @@
/* The BSP header file has a CIR_CFG, but no mod clock uses this definition */
static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M",
- 0x0cc, BIT(8), 0);
+ 0x0cc, BIT(1), 0);
static SUNXI_CCU_GATE(dram_ve_clk, "dram-ve", "pll-ddr",
0x100, BIT(0), 0);
- Edit dts: arch/arm/boot/dts/suniv-f1c100s-licheepi-nano.dts
&usb_otg {
dr_mode = "otg"; // Change this from otg to host!
status = "okay";
};
- Someone suggests to change this as well, but I find that changing this hangs the usb host operation:
drivers/usb/musb/sunxi.c: line 742
- of_device_is_compatible(np, "allwinner,suniv-musb")) {
+ of_device_is_compatible(np, "allwinner,suniv-f1c100s-musb")) {
git clone https://github.com/Lichee-Pi/u-boot.git -b nano-v2018.01
cd u-boot
make ARCH=arm licheepi_nano_spiflash_defconfig
make ARCH=arm menuconfig
# Edit the followings
# [*] Enable boot arguments
= console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=jffs2
# [*] Enable a default value for bootcmd
= sf probe 0 50000000; sf read 0x80C00000 0x100000 0x4000; sf read 0x80008000 0x110000 0x400000; bootz 0x80008000 - 0x80C00000
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4
sudo ../sunxi-tools/sunxi-fel -p spiflash-write 0 u-boot-sunxi-with-spl.bin
https://wiki.dave.eu/index.php/Change_Linux_Command_Line_Parameter_from_U-boot http://bbs.lichee.pro/d/41-nano-spi-flash https://linux-sunxi.org/FEL/USBBoot
http://nano.lichee.pro/build_sys/kernel.html http://nano.lichee.pro/build_sys/build_flash.html http://nano.lichee.pro/step_by_step/two_sunxi-tools.html https://whycan.cn/t_2179_2.html