Skip to content

Conversation

@sonicpp
Copy link

@sonicpp sonicpp commented May 10, 2022

Hi,
this is my effort to bring PineCube IP camera to ThingOS (and hopefully to MotionEyeOS as well). I already sent support to Buildroot (but its not ben accepted yet, tho), so adding support to ThingOS was my next step.

This board has Wifi, which can also act as AP - both client/AP tested and works in ThingOS. But not everything is fully functional yet (therefore the WIP), like fwupdate will fail if I use losetup from Busybox (workaround to this is to use losetup from util-linux, but since you use Busybox's losetup in ThingOS, I want to make it work for PineCube as well) with following error:

[   46.109854] loop3: detected capacity change from 0 to 634880
[   46.144625] loop_set_status: loop3 () has still dirty pages (nrpages=2)
losetup: /data/.fwupdate/firmware.img: Resource temporarily unavailable

If I go around this issue and upgrade the firmware, there is one more error in upgrade procedure - once system reboots to initramfs, it will make the upgrade but will hang during the reboot with following error (but the upgrade procedure is finished - if I do a hard reset, the board will boot to a new firmware):

[   25.742780] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
[   25.751200] CPU: 0 PID: 1 Comm: init Not tainted 5.15.0 #2
[   25.756684] Hardware name: Allwinner sun8i Family
[   25.761395] [<c010d6ec>] (unwind_backtrace) from [<c0109f1c>] (show_stack+0x10/0x14)
[   25.769155] [<c0109f1c>] (show_stack) from [<c083ef2c>] (dump_stack_lvl+0x40/0x4c)
[   25.776729] [<c083ef2c>] (dump_stack_lvl) from [<c083c37c>] (panic+0xf8/0x2e0)
[   25.783951] [<c083c37c>] (panic) from [<c0120a68>] (do_exit+0x9a4/0x9a8)
[   25.790656] [<c0120a68>] (do_exit) from [<c0121a3c>] (do_group_exit+0x3c/0xb8)
[   25.797881] [<c0121a3c>] (do_group_exit) from [<c0121ac8>] (__wake_up_parent+0x0/0x18)
[   25.805808] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000 ]---

Would you be interested in adding support for PineCube, and if so, any advise to showed errors?

In first commit I also added the 8189es package, which is in upstream Buildroot, but not in thingOS for some reason.

Thanks,
Jan

sonicpp added 2 commits May 8, 2022 13:28
Add support for PineCube IP camera. This board has WiFi (supports
creating AP), RJ45 ethernet, UART, USB and micro-usb for power.
@ccrisan
Copy link
Owner

ccrisan commented May 22, 2022

In first commit I also added the 8189es package, which is in upstream Buildroot, but not in thingOS for some reason.

If it's present in BuildRoot, please add it with a git cherry-pick command so that it's easier for us to merge upstream versions into thingOS.

losetup: /data/.fwupdate/firmware.img: Resource temporarily unavailable

Honestly I have no idea what generates this error. I'd prefer keeping things simple and using busybox applets as much as possible.

If I go around this issue and upgrade the firmware, there is one more error in upgrade procedure...

This looks a bit like wrong kernel arguments with regards to init. I'd need to see the entire kernel log to be sure about that.

Would you be interested in adding support for PineCube, and if so, any advise to showed errors?

Generally yes, why not, as long as there's someone taking care of the board every now and then.

@@ -0,0 +1 @@
OS_AP="wlan0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the AP interface name here sould be wlan0? Generally, the kernel will use wlan0 to identify the Wi-Fi network card and generate an ap0 interface.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100 % sure how AP should work. With default settings (ap0), it fails with following lines:

 * Starting hostapd on ap0: done
 * Starting dnsmasq: SIOCSIFADDR: No such device
ap0: ERROR while getting interface flags: No such device

When I change it to wlan0, it works. rtl8189es is out-of-tree driver, so who knows what behavior we can expect.
I also see driver logging following lines (among many others) - maybe it fails to generate ap0 interface?
[ 25.790226] RTW: cfg80211_rtw_add_virtual_intf(phy0) name:ap0, type:3
[ 25.796709] RTW: WARN adapter pool empty!
[ 25.800840] RTW: cfg80211_rtw_add_virtual_intf(phy0) wdev:00000000, ret:-19

@sonicpp
Copy link
Author

sonicpp commented Sep 26, 2022

Hi,
just letting you know that first bug with losetup is finally fixed so I am back working on Pinecube support. It was a kernel bug fixed in 5.19 by this patch series. There were previous not merget attempts like this one. Reason why it worked in losetup from util-linux and not with busybox implementation is because busybox uses older system calls LOOP_SET_FD and LOOP_SET_STATUS64:

open("/dev/loop4", O_RDWR|O_LARGEFILE)  = 4
ioctl(4, LOOP_SET_FD, 3)                = 0
ioctl(4, LOOP_SET_STATUS64, {lo_offset=0x6400000, lo_number=0, lo_flags=0, lo_file_name="/data/.fwupdate/firmware.img", ...}) = 0

while util-linux uses newer single system call LOOP_CONFIGURE (available since Linux 5.8) (even for older kernels util-linux would probably work, since there is some fix for call returning EAGAIN):

open("/dev/loop4", O_RDWR|O_LARGEFILE|O_CLOEXEC) = 4
ioctl(4, LOOP_CONFIGURE, {fd=3, block_size=0, info={lo_offset=0x6400000, lo_number=0, lo_flags=0, lo_file_name="/data/.fwupdate/firmware.img", ...}}) = 0

Meanwhile I sent new version of patch with Pinecube support for Buildroot.

@ccrisan
Copy link
Owner

ccrisan commented Sep 28, 2022

The system will try to generate an AP interface for all the existing STA interfaces (e.g. for wlan0 will create an ap0). So the AP interfaces should always be called apX.

There might be a bug there when the AP interface cannot be brought up and I'll make sure to look into it when I get some spare time.

@sonicpp
Copy link
Author

sonicpp commented Sep 29, 2022

Well I guess it is a driver/kernel bug, since for other devices (like rpi) it creates ap0, but with this device it fails to create ap0, but works with wlan0. Maybe I should give it some manual tests with hostapd and ask here: https://github.com/jwrdegoede/rtl8189ES_linux/ (repository used by Buildroot for this driver) ?

@sonicpp
Copy link
Author

sonicpp commented Oct 7, 2022

Ok I fixed the last error I was facing. This

 * Copying root image                                                                                                                                                                                                                       
200+0 records in
200+0 records out 
 * Cleaning up
 * Switching to normal boot
 * Unmounting data partition
[   26.652697] EXT4-fs (mmcblk0p3): unmounting filesystem.
 * Unmounting boot partition
 * Syncing
 * Rebooting[   26.725245] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
[   26.733652] CPU: 0 PID: 1 Comm: init Not tainted 5.19.10 #1
[   26.739226] Hardware name: Allwinner sun8i Family
[   26.743939]  unwind_backtrace from show_stack+0x10/0x14
[   26.749184]  show_stack from dump_stack_lvl+0x40/0x4c
[   26.754247]  dump_stack_lvl from panic+0x10c/0x310
[   26.759046]  panic from do_exit+0x944/0xa18
[   26.763238]  do_exit from do_group_exit+0x34/0xac
[   26.767947]  do_group_exit from __wake_up_parent+0x0/0x14
[   26.773361] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000 ]---

/init: line 63: can't create /proc/sysrq-trigger: nonexistent directory

Can be easily fixed by adding CONFIG_MAGIC_SYSRQ=y to kernel (extra) config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants