页次: 1
之前和你一样是小白,但是我现在点亮了。
目前找到了这篇文章,看的稀里糊涂,主要是荔枝派nano上烧写的linux,里面也没gcc呀
难道说需要我在ubuntu上编译好,然后往荔枝派nano的设备树上挂载?
用了两天时间,终于一步一步的从uboot烧录,到linux编译烧录,到根文件烧录,系统跑起来了。我这里也记录了整个过程,方便大家:
https://www.cnblogs.com/scy251147/p/14856721.html
https://www.cnblogs.com/scy251147/p/14858574.html
目前已经成功进入系统。
现在有个问题,怎么利用嵌入式linux开发的方式来点亮一个led等。
我说的嵌入式开发的方式,是指按照如下方式:
module_init(led_init);
module_exit(led_exit);
MODULE_LICENSE("GPL");
其中module_init和module_exit都是linux定义好的模块初始化和模块卸载的操作,我们只需要实现其中的具体逻辑,和arduino目前的开发模式有点像。
请问各位大佬,这个该如何开始?
uboot正常了,第一分区放了zimage和dtb文件,第二分区放了根文件系统,但是启动报错
是不是根文件系统有问题?有大佬遇到过吗?
日志如下:
U-Boot 2018.01 (Jun 07 2021 - 14:56:21 -0700) Allwinner Technology
CPU: Allwinner F Series (SUNIV)
Model: Lichee Pi Nano
DRAM: 32 MiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment
In: serial@1c25000
Out: serial@1c25000
Err: serial@1c25000
Net: No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot: 0
reading zImage
3844528 bytes read in 200 ms (18.3 MiB/s)
reading suniv-f1c100s-licheepi-nano.dtb
7583 bytes read in 25 ms (295.9 KiB/s)
## Flattened Device Tree blob at 83000000
Booting using the fdt blob at 0x83000000
Loading Device Tree to 816fb000, end 816ffd9e ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.15.0-rc8-licheepi-nano (scy@ubuntu) (gcc version 6.1.1 2016071
[ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[ 0.000000] CPU: VIVT data cache, VIVT instruction cache
[ 0.000000] OF: fdt: Machine model: Lichee Pi Nano
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 8128
[ 0.000000] Kernel command line: console=ttyS0,115200 panic=5 root=/dev/mmcblk0p2 rootwai
[ 0.000000] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.000000] Memory: 22684K/32768K available (6144K kernel code, 236K rwdata, 1388K rodata)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xc2800000 - 0xff800000 ( 976 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xc2000000 ( 32 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0x(ptrval) - 0x(ptrval) (7136 kB)
[ 0.000000] .init : 0x(ptrval) - 0x(ptrval) (1024 kB)
[ 0.000000] .data : 0x(ptrval) - 0x(ptrval) ( 237 kB)
[ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) ( 245 kB)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000046] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[ 0.000109] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 796s
[ 0.000615] Console: colour dummy device 80x30
[ 0.000704] Calibrating delay loop... 203.16 BogoMIPS (lpj=1015808)
[ 0.070224] pid_max: default: 32768 minimum: 301
[ 0.070530] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.070569] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.072012] CPU: Testing write buffer coherency: ok
[ 0.073668] Setting up static identity map for 0x80100000 - 0x80100058
[ 0.076136] devtmpfs: initialized
[ 0.082303] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1s
[ 0.082363] futex hash table entries: 256 (order: -1, 3072 bytes)
[ 0.082614] pinctrl core: initialized pinctrl subsystem
[ 0.084469] random: get_random_u32 called from bucket_table_alloc+0x80/0x1bc with crng_in0
[ 0.084709] NET: Registered protocol family 16
[ 0.085991] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.087797] cpuidle: using governor menu
[ 0.113342] SCSI subsystem initialized
[ 0.113663] usbcore: registered new interface driver usbfs
[ 0.113806] usbcore: registered new interface driver hub
[ 0.114010] usbcore: registered new device driver usb
[ 0.114444] pps_core: LinuxPPS API ver. 1 registered
[ 0.114471] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giomett>
[ 0.114531] PTP clock support registered
[ 0.114968] Advanced Linux Sound Architecture Driver Initialized.
[ 0.115848] random: fast init done
[ 0.116437] clocksource: Switched to clocksource timer
[ 0.142371] NET: Registered protocol family 2
[ 0.143797] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.143872] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.143922] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.144186] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.144244] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.144698] NET: Registered protocol family 1
[ 0.145869] RPC: Registered named UNIX socket transport module.
[ 0.145910] RPC: Registered udp transport module.
[ 0.145927] RPC: Registered tcp transport module.
[ 0.145943] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.148169] NetWinder Floating Point Emulator V0.97 (double precision)
[ 0.149993] Initialise system trusted keyrings
[ 0.150526] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[ 0.168047] NFS: Registering the id_resolver key type
[ 0.168130] Key type id_resolver registered
[ 0.168150] Key type id_legacy registered
[ 0.181367] Key type asymmetric registered
[ 0.181405] Asymmetric key parser 'x509' registered
[ 0.181601] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[ 0.181637] io scheduler noop registered
[ 0.181657] io scheduler deadline registered
[ 0.182408] io scheduler cfq registered (default)
[ 0.182442] io scheduler mq-deadline registered
[ 0.182461] io scheduler kyber registered
[ 0.183526] sun4i-usb-phy 1c13400.phy: Couldn't request ID GPIO
[ 0.193381] suniv-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[ 0.360850] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[ 0.367539] console [ttyS0] disabled
[ 0.387779] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 23, base_baud = 6250000) is a A
[ 0.861934] console [ttyS0] enabled
[ 0.872381] panel-simple panel: panel supply power not found, using dummy regulator
[ 0.881764] SCSI Media Changer driver v0.25
[ 0.889522] m25p80 spi0.0: unrecognized JEDEC id bytes: 0b, 40, 18
[ 0.896264] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.902913] ehci-platform: EHCI generic platform driver
[ 0.908470] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.914695] ohci-platform: OHCI generic platform driver
[ 0.920373] usbcore: registered new interface driver usb-storage
[ 0.927401] udc-core: couldn't find an available UDC - added [g_cdc] to list of pending ds
[ 0.936343] i2c /dev entries driver
[ 0.996575] sunxi-mmc 1c0f000.mmc: base:0x(ptrval) irq:19
[ 1.003952] usbcore: registered new interface driver usbhid
[ 1.009649] usbhid: USB HID core driver
[ 1.031521] NET: Registered protocol family 17
[ 1.036216] Key type dns_resolver registered
[ 1.042823] Loading compiled-in X.509 certificates
[ 1.061299] sun4i-drm display-engine: bound 1e60000.display-backend (ops 0xc07394f8)
[ 1.070198] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc07387dc)
[ 1.077988] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[ 1.084595] [drm] No driver support for vblank timestamp query.
[ 1.138991] Console: switching to colour frame buffer device 60x34
[ 1.142211] mmc0: host does not support reading read-only switch, assuming write-enable
[ 1.145901] mmc0: new high speed SDXC card at address aaaa
[ 1.147152] mmcblk0: mmc0:aaaa SN64G 59.5 GiB
[ 1.162583] mmcblk0: p1 p2
[ 1.185823] sun4i-drm display-engine: fb0: frame buffer device
[ 1.193026] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[ 1.202284] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc notr
[ 1.214207] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[ 1.220181] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[ 1.230311] hub 1-0:1.0: USB hub found
[ 1.234308] hub 1-0:1.0: 1 port detected
[ 1.239985] using random self ethernet address
[ 1.244457] using random host ethernet address
[ 1.250909] usb0: HOST MAC da:9f:cf:9e:80:f1
[ 1.255287] usb0: MAC 52:86:68:f9:fd:1b
[ 1.259340] g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008
[ 1.266882] g_cdc gadget: g_cdc ready
[ 1.271430] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 1.289744] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 1.296618] ALSA device list:
[ 1.299605] #0: Loopback 1
[ 1.303446] platform regulatory.0: Direct firmware load for regulatory.db failed with err2
[ 1.312163] cfg80211: failed to load regulatory.db
[ 1.319020] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[ 1.345427] EXT4-fs (mmcblk0p2): recovery complete
[ 1.350432] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 1.358762] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 1.367322] devtmpfs: mounted
[ 1.375025] Freeing unused kernel memory: 1024K
[ 1.402443] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
[ 1.402443]
[ 1.411592] CPU: 0 PID: 1 Comm: init Not tainted 4.15.0-rc8-licheepi-nano #1
[ 1.418620] Hardware name: Allwinner suniv Family
[ 1.423401] [<c010e73c>] (unwind_backtrace) from [<c010b8a8>] (show_stack+0x10/0x14)
[ 1.431154] [<c010b8a8>] (show_stack) from [<c01168d8>] (panic+0xb8/0x230)
[ 1.438031] [<c01168d8>] (panic) from [<c0118114>] (do_exit+0x950/0x9a4)
[ 1.444733] [<c0118114>] (do_exit) from [<c0118cf8>] (do_group_exit+0x3c/0xb4)
[ 1.451951] [<c0118cf8>] (do_group_exit) from [<c01219dc>] (get_signal+0x198/0x4d0)
[ 1.459609] [<c01219dc>] (get_signal) from [<c010ab18>] (do_signal+0xc4/0x418)
[ 1.466834] [<c010ab18>] (do_signal) from [<c010b02c>] (do_work_pending+0xb0/0xc0)
[ 1.474404] [<c010b02c>] (do_work_pending) from [<c0107ee8>] (slow_work_pending+0xc/0x20)
[ 1.482571] Rebooting in 5 seconds..
[ 7.461804] Reboot failed -- System halted
结贴, 是因为suniv.h中需要配置
/* bootcmd 保存着 uboot 默认命令, uboot 倒计时结束以后就会执行 bootcmd 中的命令 */
/* bootargs 保存着 uboot 传递给 Linux 内核的参数*/
sudo nano /include/configs/suniv.h
/* 添加以下代码(mmc 0为TF卡,1是第一分区,文件系统为fat32,把zImage和dtb文件拷入DRAM)*/
#define CONFIG_BOOTCOMMAND "fatload mmc 0:1 0x80800000 zImage; " \
"fatload mmc 0:1 0x83000000 suniv-f1c100s-licheepi-nano.dtb; " \
"bootz 0x80800000 - 0x83000000;"
/* 继续添加(linux将使用uart0进行交互,死机5s重启,根文件系统在mmc0(tf卡)第二分区(EXT4),等待 mmc 设备初始化完成以后再挂载,开启读写权限) */
#define CONFIG_BOOTARGS "console=ttyS0,115200 panic=5 root=/dev/mmcblk0p2 rootwait rw "
/* 回到u-boot目录进行编译 */
make ARCH=arm menuconfig
/* 取消勾选 [] Enable a default value for bootcmd */
/* 勾选 [v] Enable boot arguments;*/
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j16
=> bdinfo
arch_number = 0x00000000
boot_params = 0x80000100
DRAM bank = 0x00000000
-> start = 0x80000000
-> size = 0x02000000
baudrate = 115200 bps
TLB addr = 0x81FF0000
relocaddr = 0x81F78000
reloc off = 0x00878000
irq_sp = 0x81E55D90
sp start = 0x81E55D80
Early malloc usage: 118 / 400
fdt_blob = 81e55da8
=> print
arch=arm
baudrate=115200
board=sunxi
board_name=sunxi
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${pre}
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};i
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddrf
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=fel mmc0 usb0 pxe dhcp
bootcmd=run distro_bootcmd
bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp};
bootcmd_fel=if test -n ${fel_booted} && test -n ${fel_scriptaddr}; then echo 'i
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcmd_usb0=setenv devnum 0; run usb_boot
bootdelay=2
bootfstype=fat
bootm_size=0x1700000
console=ttyS0,115200
cpu=arm926ejs
devnum=0
devplist=1
devtype=mmc
dfu_alt_info_ram=kernel ram 0x80500000 0x1000000;fdt ram 0x80C00000 0x100000;r0
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
fdt_addr_r=0x80C00000
fdtcontroladdr=81e55da8
fdtfile=suniv-f1c100s-licheepi-nano.dtb
fel_booted=1
fileaddr=80c00000
filesize=1d9f
kernel_addr_r=0x80500000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${pref}
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_i
partitions=name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};name=loader;
preboot=usb start
pxefile_addr_r=0x80D00000
ramdisk_addr_r=0x80D50000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; fo;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env e
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n e
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prei
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} $e
scriptaddr=0x80C50000
soc=sunxi
stderr=serial@1c25000
stdin=serial@1c25000
stdout=serial@1c25000
usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dei
uuid_gpt_esp=c12a7328-f81f-11d2-ba4b-00a0c93ec93b
uuid_gpt_system=69dad710-2ce4-4e3c-b16c-21a1d49abed3
Environment size: 4545/131068 bytes
uboot编译完毕后,烧录完毕,设备树和根文件系统都装好了,但是uboot无法引导进入系统:
DRAM: 32 MiB
Trying to boot from MMC1
U-Boot 2018.01 (Jun 06 2021 - 07:18:09 -0700) Allwinner Technology
CPU: Allwinner F Series (SUNIV)
Model: Lichee Pi Nano
DRAM: 32 MiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment
In: serial@1c25000
Out: serial@1c25000
Err: serial@1c25000
Net: No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
reading /suniv-f1c100s-licheepi-nano.dtb
7583 bytes read in 25 ms (295.9 KiB/s)
starting USB...
No controllers found
USB is stopped. Please issue 'usb start' first.
starting USB...
No controllers found
No ethernet found.
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-sunxi
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
starting USB...
No controllers found
No ethernet found.
No ethernet found.
=>
想问问各位,上面的uboot引导是不是有问题呀?
scy@ubuntu:~/linux-mi/linux-f1c100s-480272lcd-test$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j16
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC scripts/recordmcount
HOSTCC scripts/sortextable
HOSTCC scripts/asn1_compiler
HOSTCC scripts/sign-file
HOSTCC scripts/extract-cert
HOSTCC scripts/insert-sys-cert
CHK scripts/mod/devicetable-offsets.h
HOSTCC scripts/selinux/genheaders/genheaders
HOSTCC scripts/selinux/mdp/mdp
In file included from scripts/selinux/mdp/mdp.c:49:
./security/selinux/include/classmap.h:247:2: error: #error New address family defined, please update secclass_map.
247 | #error New address family defined, please update secclass_map.
| ^~~~~
In file included from scripts/selinux/genheaders/genheaders.c:19:
./security/selinux/include/classmap.h:247:2: error: #error New address family defined, please update secclass_map.
247 | #error New address family defined, please update secclass_map.
| ^~~~~
make[3]: *** [scripts/Makefile.host:90: scripts/selinux/mdp/mdp] Error 1
make[2]: *** [scripts/Makefile.build:575: scripts/selinux/mdp] Error 2
make[2]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.host:90: scripts/selinux/genheaders/genheaders] Error 1
make[2]: *** [scripts/Makefile.build:575: scripts/selinux/genheaders] Error 2
make[1]: *** [scripts/Makefile.build:575: scripts/selinux] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:556: scripts] Error 2
报错信息如上,看上去感觉是不是哪里的环境配错了?
页次: 1