Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mvebu: add support for Turris Omnia #1210

Closed
wants to merge 3 commits into from
Closed

mvebu: add support for Turris Omnia #1210

wants to merge 3 commits into from

Conversation

rmounce
Copy link
Contributor

@rmounce rmounce commented Jul 9, 2017

Adds support for the Turris Omnia and builds an image in its native
'medkit' format. This is a rootfs tar, initial flash is via built-in
recovery which formats the internal eMMC storage as btrfs and extracts the
image. sysupgrade is not currently implemented. It is planned to use the
same 'medkit' image with metadata for sysupgrade.

armada-385-turris-omnia.dts was added to the mainline kernel after 4.9.
It has been backported as-is and patched separately so that the dts file
may be removed for later kernels.

Notable hardware support omissions are support for switching between SFP
cage and copper PHY, and RGB LED control.

Specifications:

  • Marvell Armada 385 1.6GHz dual-core ARMv7 CPU
  • 1GB DDR3 RAM
  • 8GB eMMC Flash
  • 5x Gigabit LAN via Marvell 88E6176 Switch (2x RGMII CPU ports)
  • 1x switchable RJ45 (88E1514 PHY) / SFP SGMII WAN
  • 2x USB 3.0
  • 12x dimmable RGB LEDs controlled by independent microcontroller
  • 3x Mini PCIe slots
  • Compex WLE200N2 Mini PCIe AR9287 2x2 802.11b/g/n (2.4GHz)
  • Compex WLE900VX Mini PCIe QCA9880 3x3 802.11ac (2.4 / 5GHz)

Flash instructions:
(in a state of flux depending on image approach taken)

@pepe2k pepe2k added the mvebu label Jul 10, 2017
@danrl
Copy link

danrl commented Jul 10, 2017

Wow! Thank you so much for this!

@@ -60,6 +60,8 @@ CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_SD=y
CONFIG_BLK_MQ_PCI=y
CONFIG_BOUNCE=y
CONFIG_BTRFS_FS=y
Copy link
Contributor

Choose a reason for hiding this comment

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

No, this shouldn't be enabled by default for mvebu. Use the package instead if you need support however I don't see why this should be in by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

btrfs is used for the rootfs, it can't be distributed as a module. The only way around this is to use a different filesystem which will complicate the flashing process somewhat.

ext4 and F2FS are already in there just for the ClearFog, so there is some precedent. I will test the impact this has on the kernel image size.

Copy link
Contributor Author

@rmounce rmounce Jul 11, 2017

Choose a reason for hiding this comment

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

Quick comparison
ext4 + F2FS + btrfs: 2.426 MiB
ext4 + F2FS (current image): 2.103 MiB
(without ClearFog support): 1.927 MiB

I had hoped to maintain a simple flashing process, however seeing this I will look at the possibility of using a ClearFog-like eMMC layout and performing a somewhat more manual initial flash via built-in OpenWrt-based Omnia recovery partition. I would at least like to avoid requiring use of a serial cable for this process (though at least the pin header is populated in the factory!)

Copy link
Contributor

Choose a reason for hiding this comment

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

I would at least like to avoid requiring use of a serial cable for this process (though at least the pin header is populated in the factory!)

Does the bootloader have an automated tftp recovery mode? If it does you can just send it an initramfs image and then you can ssh in and do a sysupgrade (which will reformat if needed).
If you have a sysupgrade working, anyway.

Copy link
Contributor Author

@rmounce rmounce Jul 11, 2017

Choose a reason for hiding this comment

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

There is no automated tftp recovery mode. Serial is required to access u-boot for tftp and also as it turns out to use the built-in OpenWrt recovery image.

https://www.turris.cz/doc/en/howto/omnia_factory_reset

The only way I can think to get the Omnia to do anything other than boot from internal btrfs without opening it/serial is to use fw_setenv from the factory OS to set tftp for next boot.

(thinking out loud) It may also be possible to write a script to run on Turris OS that prepares fw_setenv for booting a ClearFog-like image, downloads the LEDE eMMC image to /tmp/ and then dd's it on top of the mounted btrfs filesystem. A dirty hack, but it would avoid having to tftp from another machine.

I quite liked the concept of using the Omnia's built-in recovery and rollback built on btrfs, but writing sysupgrade scripts (and probably also adding packages for btrfs userland tools) is increasingly seeming like it will be a nuisance all while adding bloat to the mvebu kernel for the sake of bending to one device's factory partition layout.

I will experiment over the coming days with tftp booting my Omnia, flashing FAT/squashfs image using ClearFog sysupgrade scripts and then u-booting from this, and test flashing from a running btrfs environment.

Copy link
Member

Choose a reason for hiding this comment

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

If the rootfs is BTRFS this is fine. Anything else does not make sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not fine as it bloats all other targets and btrfs isn't really a great idea on nand either.

Copy link
Contributor Author

@rmounce rmounce Jul 12, 2017

Choose a reason for hiding this comment

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

This is not raw NAND where UBIFS should be used, eMMC devices have a flash translation layer. F2FS may be optimised for this case and I would choose it if starting from scratch, but that does not really make Btrfs (or ext4) a bad idea.

To be clear, I did not choose Btrfs because I think it's a neat FS. Btrfs is the only FS the Omnia's default u-boot environment will attempt to boot from, and it is the only FS that built-in recovery will format.

I would prefer to reach some consensus on this matter before doing any further work towards the current (bloat-inducing) medkit/Btrfs approach or alternative (and more complicated for end users) TFTP flash, u-boot environment update, ClearFog-like sysupgrade approach. I still not even sure which I prefer...

I do not know the ins and outs of the build system, but would it not be possible to build a separate kernel for the Omnia in order to contain the Btrfs bloat?

KERNEL := dtb | kernel-bin
DEVICE_DTS := armada-385-turris-omnia
DEVICE_TITLE := Turris Omnia
DEVICE_PACKAGES := swconfig wpad-mini kmod-ath9k kmod-ath10k ath10k-firmware-qca988x
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should include wifi drivers by default as not all(?) devices shipped with Atheros/QCA wifi?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Case for exclusion: It increases the size of images and take some space for users that don't have WiFi modules.

Case for inclusion: The Omnia has a very large amount of storage and I assume that a majority shipped with the WiFi modules. <1MB out of 8GB is negligible.

I think it is more likely that space-conscious users will be building their own images, while those downloading images with the default configuration will be expecting some level of functionality out of the box.

There, I have expressed my opinion. Hopefully it's settled faster than the last time I was involved in this discussion. #931

Copy link

Choose a reason for hiding this comment

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

Maybe @oerdnj can give some numbers of how many Omnia shipped without wifi so we have some data added to the discussion.

Copy link
Member

Choose a reason for hiding this comment

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

Enough storage, so let's not block the PR over this.

Copy link

Choose a reason for hiding this comment

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

I have notified the Turris team about this PR, hopefully someone will pop-up and comment.

Copy link
Member

@stintel stintel left a comment

Choose a reason for hiding this comment

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

The usual question: was all of this submitted upstream?

@@ -26,6 +26,9 @@ armada-385-linksys-rango)
armada-xp-linksys-mamba)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
;;
armada-385-turris-omnia)
Copy link
Member

Choose a reason for hiding this comment

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

Please maintain alphabetical order.

@@ -60,6 +60,8 @@ CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_SD=y
CONFIG_BLK_MQ_PCI=y
CONFIG_BOUNCE=y
CONFIG_BTRFS_FS=y
Copy link
Member

Choose a reason for hiding this comment

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

If the rootfs is BTRFS this is fine. Anything else does not make sense.

@@ -39,6 +39,11 @@ armada-388-clearfog-*)
ucidef_add_switch "switch0" \
"0:lan:5" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5u@eth1" "6:lan:6"
;;
armada-385-turris-omnia)
Copy link
Member

Choose a reason for hiding this comment

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

Same here. One could argue that it currently isn't ordered alphabetically, but let's not make things worse. Ideally, fix the order in a separate commit first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed + added separate commit to fix initial order.

KERNEL := dtb | kernel-bin
DEVICE_DTS := armada-385-turris-omnia
DEVICE_TITLE := Turris Omnia
DEVICE_PACKAGES := swconfig wpad-mini kmod-ath9k kmod-ath10k ath10k-firmware-qca988x
Copy link
Member

Choose a reason for hiding this comment

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

Enough storage, so let's not block the PR over this.

@neheb
Copy link
Contributor

neheb commented Jul 12, 2017

Another issue I have is the permissions are off. Only root has permission for anything, making LuCI unusable.

Also, does sysupgrade work with the medkit file?

@rmounce
Copy link
Contributor Author

rmounce commented Jul 12, 2017

LuCI appears to work fine here. Permissions are preserved, only owner/group is changed to root. Or am I missing something else?

As noted in the commit message sysupgrade is not currently implemented, but it is possible. The medkit file is already a metadata image, I plan to add upgrade scripts and btrfs userland tools in a later commit.

@neheb
Copy link
Contributor

neheb commented Jul 12, 2017

All the permissions under /www are X00 where X is 6 or 7.

@rmounce
Copy link
Contributor Author

rmounce commented Jul 12, 2017

Where are you seeing this? Permissions appear fine in the medkit tar and the same after installation.

drwxr-xr-x 0/0               0 2017-07-10 00:51 ./www/
drwxr-xr-x 0/0               0 2017-07-10 00:51 ./www/cgi-bin/
-rwxr-xr-x 0/0             135 2017-07-10 00:51 ./www/cgi-bin/luci
-rw-r--r-- 0/0             495 2017-07-10 00:51 ./www/index.html
drwxr-xr-x 0/0               0 2017-07-10 00:51 ./www/luci-static/
drwxr-xr-x 0/0               0 2017-07-10 00:51 ./www/luci-static/bootstrap/
-rw-r--r-- 0/0           50527 2017-07-10 00:51 ./www/luci-static/bootstrap/cascade.css

@neheb
Copy link
Contributor

neheb commented Jul 12, 2017 via email

@rmounce
Copy link
Contributor Author

rmounce commented Jul 12, 2017

Perhaps there is some issue with your build environment? The above listing is from my own medkit build with LuCI.

I built the above image on Debian 9 (unprivileged LXC container under Proxmox 5). I am building now on macOS to confirm that this is also fine.

Edit: Same result on macOS (permissions are correct). @neheb could you please provide more information about your build environment?

@neheb
Copy link
Contributor

neheb commented Jul 12, 2017

I'm running on fedora 25. I happen to be building on an NTFS drive but oddly enough, i've never encountered this issue.

@KanjiMonster
Copy link
Member

I also started poking at the Turris Omnia (before I was aware of your work), and went the modified u-boot bootargs / resuse of the clearfog code way (which does work fine). Obviously this is no good solution, as it requires serial access.

My best idea so far to get both easy installation and a LEDE layout (readonly-fs + overlay) is to create a second stage u-boot and the following partition layout:

p0: btrfs
+ boot/zimage - second stage u-boot
+ boot/dtb - so original u-boot doesn't complain (if actually needed)
p1: vfat (or any other FS already supported by the kernel)
+ zImage - actual kernel - could also very well be a fit image
+ dtb 
p2: squashfs
p3: f2fs (overlay)

So the sd-card image would span p0 to p2. The second stage u-boot in p0 is in this case responsible for booting the kernel with a modified commandline to make sure the rootfs points to the right partition.

For easy flashing, my idea is to include the sdcard image in the turris-medkit*.tar.gz, and let the second stage u-boot check for it and write the image to the eMMC if it finds it.

That way we don't need to modify the u-boot env, don't need serial access, can easily implement sysupgrade and don't need btrfs in the kernel.

Of course writing a custom u-boot is easier said then done, as the omnia support isn't upstream. Then we also need to create a host-build for the btrfs-tools to create the btrfs partition. But mkfs.btrfs does allow creating file system images with custom contents, so it should be possible to create a sd-card image that boots with the original u-boot commandline.

Comments welcome, especially those that show how we don't need a second stage u-boot ;-)

@neheb
Copy link
Contributor

neheb commented Jul 12, 2017

FWIW the omnia is geared towards relatively advanced users. Requiring serial access is not that much of a stretch.

BTW, u-boot args can be modified in userspace using fw_setenv.

@tohojo
Copy link
Contributor

tohojo commented Jul 12, 2017 via email

@neheb
Copy link
Contributor

neheb commented Jul 12, 2017

I was pitching the idea of having netconsole in the U-boot to avoid that but they argued it's a security risk since there's no switch driver in U-boot.

In any case, fw_setenv should accomplish the goal

@diizzyy
Copy link
Contributor

diizzyy commented Jul 12, 2017

Question is if we really want to pollute the tree for a handful of users or just tell them that serial access is needed. I'd vote for the serial access route in that case.

@ghost
Copy link

ghost commented Jul 12, 2017

I only can say that I prefer any method no requiring open the router and use serial console. But you are the developers, only is my opinion as Turris Omnia user.

@JamesT42
Copy link

The current way is implemented and working, it is only lacking the failsafe/overlay-fs functions. But that is no problem when we are able to use the btrfs snapshots. In Turris-OS you are able to rollback snapshots, mount the "broken" snapshot, mend your config and then activate the repaired snapshot state. So I think there is no need to fiddle with serial consoles, additional u-boots etc. because it has no advantage.

@rmounce
Copy link
Contributor Author

rmounce commented Jul 13, 2017

I think I have come up with a relatively clean and safe approach that avoids serial console and TFTP. Inspiration comes from the Debian wiki, just hold the reset button until 6 LEDs are illuminated to boot the LEDE ramdisk. From there you can SSH in and download/flash a sysupgrade image.

# run within Turris OS (tested on omnia-medkit-201706290957-minimal.tar.gz)
# first copy lede-zimage and lede-dtb to /boot/

echo '/dev/mtd0 0xC0000 0x10000 0x40000' > /etc/fw_env.config
fw_setenv tmpbootcmd 'btrload mmc 0 0x01000000 boot/lede-zimage @; btrload mmc 0 0x02000000 boot/lede-dtb @; bootz 0x01000000 - 0x02000000'
fw_setenv bootcmd 'i2c dev 1; i2c read 0x2a 0x9 1 0x00FFFFF0; setexpr.b rescue *0x00FFFFF0; if test $rescue -ge 2; then echo BOOT eMMC LEDE initramfs; run tmpbootcmd; else if test $rescue -ge 1; then echo BOOT RESCUE; run rescueboot; else echo BOOT eMMC TurrisOS FS; run mmcboot; fi; fi'

Obviously the variables will have to be changed again after flashing LEDE.

It suppose it would also be possible to create a kernel+initramfs that includes btrfs support and a script to copy the sysupgrade image from Btrfs /boot/ to /tmp/, unmount Btrfs, flash sysupgrade and set uboot variables automatically. At that point the user experience could be a matter of copying some files into Turris OS /boot/, executing a script, waiting a few minutes and then LEDE is fully flashed.

I am sorry to those who enjoy Omnia recovery features with Btrfs but this is looking like the path of least resistance to please those that want to keep the kernel lean, use established LEDE partition layout+sysupgrade, and avoid packaging extra Btrfs userland stuff.

@JamesT42
Copy link

So ext4 is ok for clearfog but btrfs is not ok for omnia? Is that the correct interpretation?

@bobafetthotmail
Copy link
Contributor

So ext4 is ok for clearfog but btrfs is not ok for omnia?

ext4 is compiled in kernel in many other devices that don't have space issues (like say kirkwoods) as it is a commonly used filesystem for external storage.

f2fs is used already in LEDE images for sdcard or for x86 images (that usually go on sdcard or usb flash storage), so again it is not uncommon.

btrfs is a kind of white elephant here, and is not truly required.

Then again, I don't see such hard space issues in mvebu target anyway, there is only one board with a kernel size of 3072k (linksys-wrt1900ac), while others have 6 MB or 8 MB or even no space constraints at all.
A kernel with btrfs is 2.4 Mb as said above.

@jow-
Copy link
Member

jow- commented Jul 13, 2017

I have no clear preference. On one hand I agree that there are no hard kernel space constraints on mvebu so we can likely affort the few hundred KB for btrfs support.

On the other hand, btrfs is a white elephant here, no other target uses it and it introduces even more variations into the already quite diverse image format zoo.

I think I would have a slight preference on consistency, means ext4/f2fs or squash+overlay for this target.

@mkresin
Copy link
Contributor

mkresin commented Jul 13, 2017

I think I would have a slight preference on consistency, means ext4/f2fs or squash+overlay for this target.

Same here

@bobafetthotmail
Copy link
Contributor

means ext4/f2fs or squash+overlay for this target.

I think ext4/f2fs does not allow easy "reset to default" or failsafe so I would prefer squash+overlay (with overlay being ext4 or f2fs as this is emmc, not raw flash) between these two.

@rmounce
Copy link
Contributor Author

rmounce commented Jul 13, 2017

I have updated my patch to re-use ClearFog image building and sysupgrade, squash+f2fs overlay. Flashing process feels like a bit of a hack to me, but it works.

@bobafetthotmail
Copy link
Contributor

bobafetthotmail commented Jul 13, 2017

it's better if you write installing instructions in the commit description. Also because afaik the LEDE wiki does not currently have pages for device-specific instructions, only for hardware specs.

@rmounce
Copy link
Contributor Author

rmounce commented Jul 13, 2017

I began doing that but the commands are too long to fit in the commit without wrapping, unless the 75-char limit only applies to prose.

I am also going to have to have a quick look now and see if there is an easy way to get initramfs and dtb as build artifacts.

@rmounce
Copy link
Contributor Author

rmounce commented Jul 13, 2017

Install process simplified slightly by appending DTB to ramdisk, and enabling ramdisk image generation by default for mvebu (so that users can download ramdisk from LEDE mirror rather than infected image from someone's Github releases).

Install process documented in commit message.

@KanjiMonster
Copy link
Member

To make the installation easier, how about we just wrap the ramdisk zImage in a turris-mediakit*.tar.gz so you can use the factory recovery flash method to boot it.

After that you can sysupgrade to a full sdcard image. This way you don't need to touch the u-boot environment manually at all.

And for the "new" boot scripts, my suggestion would be something like this (only the LEDE part and switch on failure tested; I didn't try to flash & boot a TurrisOS image again):

bootargs_lede=earlyprintk console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=auto rootwait
bootargs_turris=earlyprintk console=ttyS0,115200 rootfstype=btrfs rootdelay=2 root=b301 rootflags=subvol=@,commit=5 rw
mmcload_lede=setenv bootargs "$bootargs_lede cfg80211.freg=$regdomain"; fatload mmc 0 0x01000000 zImage @ && fatload mmc 0 0x02000000 armada-385-turris-omnia.dtb @
mmcload_turris=setenv bootargs "$bootargs_turris cfg80211.freg=$regdomain"; btrload mmc 0 0x01000000 boot/zImage @ && btrload mmc 0 0x02000000 boot/dtb @
mmcboot=run mmcload_lede || run mmcload_turris; bootz 0x01000000 - 0x02000000

The idea is to use the return value of fatload to dynamically detect whether we boot LEDE (FAT) or turrisOS (btrfs), and allow going back to TurrisOS easily without ever having to touch the environment again.

CONFIG_I2C_BOARDINFO=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_MUX=y
CONFIG_I2C_MUX_GPIO=y
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this? I don't see this used anywhere

Copy link
Member

Choose a reason for hiding this comment

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

Could someone please reply to this comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

The SFP autodetect script shipped with the omnia uses i2c to probe the EEPROM of inserted SPF modules, as well as some GPIO pins to detect changes. Not sure if this option is related to that.

If it is, I don't think there's any reason to keep it enabled for now: the image I built from this pull request seems to be lacking driver support for some of the features that script is using anyway, so updates will have to be made to add the SFP switch support...

@ghost
Copy link

ghost commented Nov 25, 2017

@bobafetthotmail thank you, very good explication.

@wackejohn for me it's working:

# date
Sat Nov 25 22:11:57 CET 2017
# hwclock -r -u /dev/rtc0 
Sat Nov 25 22:11:58 2017  0.000000 seconds

My current U-Boot bootcmd:

bootcmd=i2c dev 1; i2c read 0x2a 0x9 1 0x00FFFFF0; setexpr.b rescue *0x00FFFFF0; mw 0xf10184a0 0xfd4d4cfa; if test $rescue -ge 1; then echo BOOT RESCUE; run rescueboot; else echo BOOT eMMC FS; run mmcboot; fi

I copied it and only added mw 0xf10184a0 0xfd4d4cfa. I too tried to do date reset in U-Boot as suggests here:

rtc@a3800 {
	/*
	 * If the rtc doesn't work, run "date reset"
	 * twice in u-boot.
	 */
	status = "okay";
};

But my U-Boot does not has the command date. Because, I don't know.

@wackejohn
Copy link

wackejohn commented Nov 26, 2017

@localnet
For my omnia,that command doesn't working at all...and my u-boot also doesn't have the date command,it's in the mainline u-boot,but not in the omnia u-boot...
What system did your omnia is runing?turris os or lede?

@ghost
Copy link

ghost commented Nov 26, 2017

@wackejohn
My Turris Omnia is running LEDE, custom build of @rmounce branch mine.

@wackejohn
Copy link

@localnet
My omnia also running LEDE,that's strange....hardware problem?

@ghost
Copy link

ghost commented Nov 26, 2017

I don't know, but my BusyBox hwclock doesn't have the option -D that you used higher:

# hwclock --help
BusyBox v1.27.2 () multi-call binary.

Usage: hwclock [-r] [-s] [-w] [-t] [-l] [-u] [-f FILE]

Query and set hardware clock (RTC)

        -r      Show hardware clock time
        -s      Set system time from hardware clock
        -w      Set hardware clock from system time
        -t      Set in-kernel timezone, correct system time
                if hardware clock is in local time
        -u      Assume hardware clock is kept in UTC
        -l      Assume hardware clock is kept in local time
        -f FILE Use specified device (e.g. /dev/rtc2)

I used:

# hwclock -w -u -f /dev/rtc0
# hwclock -r -u -f /dev/rtc0 
Sun Nov 26 13:55:27 2017  0.000000 seconds

Can be interesting know if it work in TurrisOS...

@wackejohn
Copy link

@localnet
My omnia didn't use the busybox built in hwclock,I'll try the busybox built in version ....

@bobafetthotmail
Copy link
Contributor

But my U-Boot does not has the command date. Because, I don't know.

the uboot in turris omnia is customized (for example mainline uboot does not support booting from btrfs), and in general most uboots in embedded devices don't have many commands to save space or whatever.

turris omnia uboot is opensourced here https://gitlab.labs.nic.cz/turris/turris-omnia-uboot

@mibastian
Copy link

mibastian commented Nov 27, 2017

I’m happy to review and incorporate someone else’s patch to fix the RTC, but nothing will happen here if it is left to me alone.

I wish the remaining issues(are there any?) with this commit could be finally resolved.

@wackejohn
Copy link

I found that someone's wrt1900acs also have the rtc issue,see:
https://forum.openwrt.org/viewtopic.php?pid=320725#p320725
My omnia output:
root@HOME-Router:~# cat /proc/interrupts | grep rtc 42: 0 0 GIC-0 53 Level f10a3800.rtc

@stintel stintel dismissed their stale review November 29, 2017 08:51

Lost interest

@ghost
Copy link

ghost commented Nov 29, 2017

Same here:

# cat /proc/interrupts | grep rtc
 42:          0          0     GIC-0  53 Level     f10a3800.rtc

I did a reboot at monday:

# dmesg | grep -i rtc
[    1.270379] armada38x-rtc f10a3800.rtc: rtc core: registered f10a3800.rtc as rtc0
[    1.458483] armada38x-rtc f10a3800.rtc: setting system clock to 2017-11-27 18:43:41 UTC (1511808221)

The date time seems continue ok:

# hwclock -r -u
Wed Nov 29 18:54:13 2017  0.000000 seconds

@wackejohn
Copy link

@localnet
That's strange....Can you upload your LEDE image and also your uboot env?
I want to try your image to see if there is a hardware problem.Thanks.

@ghost
Copy link

ghost commented Nov 30, 2017

@wackejohn
Here is my LEDE image: https://www.dropbox.com/sh/k3ezfjrswhr6l0w/AADjdP2f0q4sfKW_aUZUAviwa?dl=0

My U-Boot environment is most complicated... Shutdown, open the router, connect the serial console... I have few time and my Omnia is in production. The only change I did was:

setenv bootcmd 'i2c dev 1; i2c read 0x2a 0x9 1 0x00FFFFF0; setexpr.b rescue *0x00FFFFF0; mw 0xf10184a0 0xfd4d4cfa; if test $rescue -ge 1; then echo BOOT RESCUE; run rescueboot; else echo BOOT eMMC FS; run mmcboot; fi'
saveenv

Try my LEDE image and if the RTC continue without working for you, I will try to get the U-Boot environment. But I will need time...

@bobafetthotmail
Copy link
Contributor

bobafetthotmail commented Nov 30, 2017

My U-Boot environment is most complicated... Shutdown, open the router, connect the serial console

I was under the impression that Turris Omnia had fw_printenv tool you can use from SSH to get a dump of the uboot envs.

@ghost
Copy link

ghost commented Nov 30, 2017

I was under the impression that Turris Omnia had fw_printenv tool you can use from SSH to get a dump of the uboot envs.

You are right, it is selected by make defconfig. I thought I needed select it explicit.

# fw_printenv
baudrate=115200
bootargs=earlyprintk console=ttyS0,115200 rootfstype=btrfs rootdelay=2 root=b301 rootflags=subvol=@,commit=5 rw
bootcmd=i2c dev 1; i2c read 0x2a 0x9 1 0x00FFFFF0; setexpr.b rescue *0x00FFFFF0; mw 0xf10184a0 0xfd4d4cfa; if test $rescue -ge 1; then echo BOOT RESCUE; run rescueboot; else echo BOOT eMMC FS; run mmcboot; fi
bootdelay=3
ethact=neta2
ethaddr=xx:xx:xx:xx:xx:xx
factory_mmcload=setenv bootargs "$bootargs cfg80211.freg=$regdomain"; btrload mmc 0 0x01000000 boot/zImage @; btrload mmc 0 0x02000000 boot/dtb @
fdt_high=0x10000000
initrd_high=0x10000000
lede_bootargs=earlyprintk console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=auto rootwait
lede_mmcload=setenv bootargs "$lede_bootargs cfg80211.freg=$regdomain"; fatload mmc 0 0x01000000 zImage; fatload mmc 0 0x02000000 armada-385-turris-omnia.dtb
mmcboot=run lede_mmcload || run factory_mmcload; bootz 0x01000000 - 0x02000000
regdomain=**
rescueboot=i2c mw 0x2a.1 0x3 0x1c 1; i2c mw 0x2a.1 0x4 0x1c 1; mw.l 0x01000000 0x00ff000c; i2c write 0x01000000 0x2a.1 0x5 4 -s; setenv bootargs "$bootargs omniarescue=$rescue"; sf probe; sf read 0x1000000 0x100000 0x700000; bootz 0x1000000
stderr=serial@12000
stdin=serial@12000
stdout=serial@12000

PS: I have edited ethaddr

@wackejohn
Copy link

wackejohn commented Dec 1, 2017

@localnet
Thank you for your LEDE image,I've tried it,and my omnia's rtc is working properly with your LEDE image.
But still not working on my own build LEDE image.

root@HOME-Router:/# hwclock
Fri Dec  1 10:30:31 2017  0.000000 seconds
root@HOME-Router:/# hwclock
Fri Dec  1 10:30:31 2017  0.000000 seconds

I think there were something misconfigured by myself,can you upload your .config and config-4.9 file?Thanks a lot.

@ghost
Copy link

ghost commented Dec 1, 2017

@wackejohn
Here are:
https://www.dropbox.com/sh/k3ezfjrswhr6l0w/AADjdP2f0q4sfKW_aUZUAviwa?dl=0

I has done changes only in LEDE packages: openwrt/luci#1422 and openwrt/packages#5040

But I haven't done changes in LEDE core:

$ git status
On branch mine
Your branch is up-to-date with 'origin/mine'.
nothing to commit, working tree clean

Can be more easy if you discard your changes and you do:

$ curl -L -O https://gist.github.com/localnet/ea4c8873b245288eaf6557d5a90ac4d3/raw/6ea5d63d91adfead31f6b2928fc9a9e582876542/turris-omnia
$ mv turris-omnia .config
$ make defconfig
$ make -j 9

PS: Edit turris-omnia, add/remove packages, as you want.

@wackejohn
Copy link

@localnet
Thank you for your reply,I've fixed this issue by using back the busybox bulit in hwclock...
Now my omnia's rtc is working properly,thanks again.

RGMII internal delay must be enabled to support some devices where PCB
trace length is short. There is no harm in enabling if unnecessary.

Patch authored by Michael Altizer <xiche@verizon.net>, rewritten to comply
with LEDE submission requirements.

Signed-off-by: Ryan Mounce <ryan@mounce.com.au>
ramdisk images must be used in the installation process for upcoming
Turris Omnia support.

Signed-off-by: Ryan Mounce <ryan@mounce.com.au>
Adds support for the Turris Omnia and builds an eMMC sysupgrade image in
the same format as the SolidRun ClearFog.

An initramfs image in the simple yet Omnia-specific 'medkit' image format
is also built in order to ease the initial flashing process.

armada-385-turris-omnia.dts was added to the mainline kernel after 4.9.
It has been backported as-is and patched separately so that the dts file
may be removed for later kernels.

Notable hardware support omissions are support for switching between SFP
cage and copper PHY, and RGB LED control.

Specifications:
- Marvell Armada 385 1.6GHz dual-core ARMv7 CPU
- 1GB DDR3 RAM
- 8GB eMMC Flash
- 5x Gigabit LAN via Marvell 88E6176 Switch (2x RGMII CPU ports)
- 1x switchable RJ45 (88E1514 PHY) / SFP SGMII WAN
- 2x USB 3.0
- 12x dimmable RGB LEDs controlled by independent MCU
- 3x Mini PCIe slots
- Optional Compex WLE200N2 Mini PCIe AR9287 2x2 802.11b/g/n (2.4GHz)
- Optional Compex WLE900VX Mini PCIe QCA9880 3x3 802.11ac (2.4 / 5GHz)
- Optional Quectel EC20 Mini PCIe LTE modem

Flash instructions:
If the U-Boot environment has been modified previously (likely manually via
serial console), first use serial to reset the default environment.
=> env default -a
=> saveenv

Method 1 - USB 'medkit' image w/o serial
- Copy lede-mvebu-turris-omnia-sysupgrade.img.gz and
omnia-medkit-lede-initramfs.tar.gz to the root of a USB flash drive
formatted with FAT32 / ext2/3/4 / btrfs / XFS.
- Disconnect other USB devices from the Omnia and connect the flash drive
to either USB port.
- Power on the Omnia and hold down the rear reset button until 4 LEDs are
illuminated, then release.
- Wait approximately 2 minutes for the Turris Omnia to flash itself with
the temporary image, during which LEDs will change multiple times.
- Connect a computer to a LAN port of the Turris Omnia with a DHCP client
- (if necessary) ssh-keygen -R 192.168.1.1
- ssh root@192.168.1.1
$ mount /dev/sda1 /mnt
$ sysupgrade /mnt/lede-mvebu-turris-omnia-sysupgrade.img.gz
- Wait another minute for the final LEDE image to be flashed. The Turris
Omnia will reboot itself and you can remove the flash drive.

Method 2 - TFTP w/ serial
- Extract omnia-medkit-lede-initramfs.tar.gz and copy dtb + zImage to TFTP
server (rename if desired)
- Connect Turris Omnia WAN port to DHCP-enabled network with TFTP server
- Connect serial console and interrupt U-Boot
=> dhcp
=> setenv serverip <tftp_server_ip_here>
=> tftpboot 0x01000000 zImage
=> tftpboot 0x02000000 dtb
=> bootz 0x01000000 - 0x02000000
- LEDE will now boot from ramdisk
- Download lede-mvebu-turris-omnia-sysupgrade.img.gz to /tmp/
$ sysupgrade /tmp/lede-mvebu-turris-omnia-sysupgrade.img.gz
- Wait another minute for the final LEDE image to be flashed. The Turris
Omnia will reboot itself.

Signed-off-by: Ryan Mounce <ryan@mounce.com.au>
@rmounce
Copy link
Contributor Author

rmounce commented Dec 6, 2017

I've successfully tested the RTC fix, included it in the u-boot environment that is set during sysupgrade, and updated this in the PR.

So that's one minor issue fixed (not that I considered it a blocker)... it would be nice to get this merged in 2017 :)

Note for people directly following my 'mine' branch, feel free but proceed at your own risk. For your own builds, best to re-base this PR's 'omnia' branch on top of LEDE master and skip any other stuff I may be tinkering with personally.

If I remember, I will upload images incorporating the RTC fix in the next few days. Otherwise, I trust that localnet has not backdoored their images or you can do your own build.

@diizzyy
Copy link
Contributor

diizzyy commented Dec 12, 2017

A bit late to the party but SolidRun just added RTC stuff to their repo.

SolidRun@2fae437
SolidRun@5371b7a

@tohojo
Copy link
Contributor

tohojo commented Dec 13, 2017

I have also managed to compile and flash an image based on this pull request. The USB-stick flashing procedure seemed to work, but the router didn't boot afterwards. Retrying with the tftp/serial approach worked. It may have had something to do with the uboot environment as I also needed to reset that to get the image to boot over tftp.

Tested-by: Toke Høiland-Jørgensen toke@toke.dk

@hauke
Copy link
Member

hauke commented Dec 16, 2017

There are some open questions mostly from @KanjiMonster could someone please take care about them, otherwise this looks ok to me.

@tohojo
Copy link
Contributor

tohojo commented Dec 19, 2017

One issue I've seen since I flashed this is that having receive offloads (GRO) enabled on the wan interface breaks my he.net 6in4 tunnel (I will only get around 1mbps of by throughput). Turning off GRO immediately unbreaks things.

I've seen this same behaviour before, but I don't recall if it was on the stock Omnia firmware or if it was on a different device...

@blogic
Copy link
Contributor

blogic commented Jan 2, 2018

With the remerge in progress, all PRs on the lede-project organisation will be closed. Please help getting this merged or rebase/post it on the openwrt project page (https://github.com/openwrt/openwrt/pulls). All remaining PRs will be closed in 30 days.

@tohojo
Copy link
Contributor

tohojo commented Jan 23, 2018

I took the liberty of fixing the few outstanding nits and reopening this against the openwrt repo. See openwrt/openwrt#684

Not trying to take credit, just trying to speed this along. @rmounce, let me know if you object :)

@rmounce rmounce closed this Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet