Skip to contentSkip to conversation

board: amarula: Add A64-Relic support

PATCH Superseded Jagan Teki 3 participants 6 messages May 28, 2018 – May 31, 2018

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH 1/2 board: amarula: Add A64-Relic support

Add initial support for Amarula A64-Relic board
with below features:
- U-Boot 2018.05
- Linux 4.17.0-rc6
- Default packages from buildroot

---
 .gitlab-ci.yml                         |  1 +
 DEVELOPERS                             |  1 +
 board/amarula/a64-relic/extlinux.conf  |  4 +++
 board/amarula/a64-relic/genimage.cfg   | 39 ++++++++++++++++++++++
 board/amarula/a64-relic/post-build.sh  |  4 +++
 board/amarula/a64-relic/readme.txt     | 60 ++++++++++++++++++++++++++++++++++
 board/amarula/a64-relic/uboot.fragment |  3 ++
 configs/amarula_a64_relic_defconfig    | 47 ++++++++++++++++++++++++++
 8 files changed, 159 insertions(+)
 create mode 100644 board/amarula/a64-relic/extlinux.conf
 create mode 100644 board/amarula/a64-relic/genimage.cfg
 create mode 100755 board/amarula/a64-relic/post-build.sh
 create mode 100644 board/amarula/a64-relic/readme.txt
 create mode 100644 board/amarula/a64-relic/uboot.fragment
 create mode 100644 configs/amarula_a64_relic_defconfig
.gitlab-ci.yml +1 -0
index e80491cdde..9663105462 100644
@@ -79,6 +79,7 @@ acmesystems_aria_g25_128mb_defconfig: *defconfig
 acmesystems_aria_g25_256mb_defconfig: *defconfig
 acmesystems_arietta_g25_128mb_defconfig: *defconfig
 acmesystems_arietta_g25_256mb_defconfig: *defconfig
+amarula_a64_relic_defconfig: *defconfig
 amarula_vyasa_rk3288_defconfig: *defconfig
 arcturus_ucls1012a_defconfig: *defconfig
 arcturus_ucp1020_defconfig: *defconfig
DEVELOPERS +1 -0
index f24ef2752e..1a893bda9d 100644
@@ -863,6 +863,7 @@ F:	board/amarula/
 F:	board/asus/
 F:	board/bananapi/
 F:	board/engicam/
+F:	configs/amarula_a64_relic_defconfig
 F:	configs/amarula_vyasa_rk3288_defconfig
 F:	configs/asus_tinker_rk3288_defconfig
 F:	board/friendlyarm/nanopi-a64/
board/amarula/a64-relic/extlinux.conf new file +4 -0
new file mode 100644
index 0000000000..9f469846bc
@@ -0,0 +1,4 @@
+label linux-4.17.0-rc3
+  kernel /Image
+  devicetree /sun50i-a64-amarula-relic.dtb
+  append console=ttyS0,115200 earlyprintk root=/dev/mmcblk1p4 rootwait
board/amarula/a64-relic/genimage.cfg new file +39 -0
new file mode 100644
index 0000000000..259c269e54
@@ -0,0 +1,39 @@
+image boot.vfat {
+	vfat {
+		files = {
+			"Image",
+			"sun50i-a64-amarula-relic.dtb",
+			"extlinux"
+		}
+	}
+	size = 64M
+}
+
+image sdcard.img {
+	hdimage {
+	}
+
+	partition spl {
+		in-partition-table = "no"
+		image = "sunxi-spl.bin"
+		offset = 8192
+	}
+
+	partition u-boot {
+		in-partition-table = "no"
+		image = "u-boot.itb"
+		offset = 40K
+		size = 1M # 1MB - 40K
+	}
+
+	partition boot {
+		partition-type = 0xC
+		bootable = "true"
+		image = "boot.vfat"
+	}
+
+	partition rootfs {
+		partition-type = 0x83
+		image = "rootfs.ext4"
+	}
+}
board/amarula/a64-relic/post-build.sh new file +4 -0
new file mode 100755
index 0000000000..ec20fca7d9
@@ -0,0 +1,4 @@
+#!/bin/sh
+BOARD_DIR="$(dirname $0)"
+
+install -m 0644 -D $BOARD_DIR/extlinux.conf $BINARIES_DIR/extlinux/extlinux.conf
board/amarula/a64-relic/readme.txt new file +60 -0

60 lines not on this page · raw message

board/amarula/a64-relic/uboot.fragment new file +3 -0
new file mode 100644
index 0000000000..7b204598bc
@@ -0,0 +1,3 @@
+# A64-Relic need few user-defined configs enable on top of
+# uboot mainline default defconfig
+CONFIG_CMD_USB_MASS_STORAGE=y
configs/amarula_a64_relic_defconfig new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.14.3
author
#1 lore raw

PATCH 2/2 board: amarula: a64-relic: Add WiFi support

Amarula A64-Relic board has AP6330 WiFi/BT combo, but does not have ethernet port. So it makes sense to enable wireless networking by default:
- add broadcom wireless firmware package to image
- add basic wireless tools to image
- add rootfs overlay with proper NVRAM file for on-board AP6330 chip
- add init script to load modules
- update readme.txt to test wifi

---
 board/amarula/a64-relic/readme.txt                 |  9 +++
 .../rootfs_overlay/etc/init.d/S02-modload          | 12 ++++
 .../rootfs_overlay/etc/modules-load.d/modules.conf |  1 +
 .../lib/firmware/brcm/brcmfmac4330-sdio.txt        | 83 ++++++++++++++++++++++
 configs/amarula_a64_relic_defconfig                | 12 ++++
 5 files changed, 117 insertions(+)
 create mode 100755 board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
 create mode 100644 board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
 create mode 100644 board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt
board/amarula/a64-relic/readme.txt +9 -0
index 534ed32e7b..18824e1669 100644
@@ -57,4 +57,13 @@ GPT:
   $ fastboot -i 0x1f3a flash esp boot.vfat
   $ fastboot -i 0x1f3a flash system rootfs.ext2
 
+WiFi
+====
+
+ # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
+   (type password and enter)
+ # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
+ # udhcpc -i wlan0
+ # ping google.com
+
 Enjoy!
board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload new file +12 -0
new file mode 100755
index 0000000000..81d85ce01c
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+
+load_modules()
+{
+	while IFS= read -r line; do
+		modprobe -a $line
+	done < "/etc/modules-load.d/modules.conf"
+}
+
+load_modules
+echo "Loading modules: OK"
board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf new file +1 -0
new file mode 100644
index 0000000000..a86ef4c668
@@ -0,0 +1 @@
+brcmfmac
board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt new file +83 -0

83 lines not on this page · raw message

configs/amarula_a64_relic_defconfig +12 -0
index 07f1a72363..d1da97ed5c 100644
@@ -45,3 +45,15 @@ BR2_PACKAGE_HOST_MTOOLS=y
 BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
 BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/amarula/a64-relic/genimage.cfg"
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/amarula/a64-relic/post-build.sh"
+BR2_ROOTFS_OVERLAY="board/amarula/a64-relic/rootfs_overlay"
+
+# wireless firmware
+BR2_PACKAGE_LINUX_FIRMWARE=y
+BR2_PACKAGE_LINUX_FIRMWARE_BRCM_BCM43XX=y
+
+# wireless tools
+BR2_PACKAGE_IW=y
+BR2_PACKAGE_WPA_SUPPLICANT=y
+BR2_PACKAGE_WPA_SUPPLICANT_NL80211=y
+BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y
+BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y
Signature · 1 line
2.14.3
#2 lore raw

PATCH 2/2 board: amarula: a64-relic: Add WiFi support

Quoted 26 lines · Jagan Teki

Amarula A64-Relic board has AP6330 WiFi/BT combo, but does not have ethernet port. So it makes sense to enable wireless networking by default:
- add broadcom wireless firmware package to image
- add basic wireless tools to image
- add rootfs overlay with proper NVRAM file for on-board AP6330 chip
- add init script to load modules
- update readme.txt to test wifi

---
 board/amarula/a64-relic/readme.txt                 |  9 +++
 .../rootfs_overlay/etc/init.d/S02-modload          | 12 ++++
 .../rootfs_overlay/etc/modules-load.d/modules.conf |  1 +
 .../lib/firmware/brcm/brcmfmac4330-sdio.txt        | 83 ++++++++++++++++++++++
 configs/amarula_a64_relic_defconfig                | 12 ++++
 5 files changed, 117 insertions(+)
 create mode 100755 board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload
 create mode 100644 board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf
 create mode 100644 board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt
board/amarula/a64-relic/readme.txt +0 -0
index 534ed32e7b..18824e1669 100644

board/amarula/a64-relic/readme.txt GPT: · line 62

Quoted 6 lines
board/amarula/a64-relic/readme.txt +3 -0
@@ -57,4 +57,13 @@ GPT:
   $ fastboot -i 0x1f3a flash esp boot.vfat
   $ fastboot -i 0x1f3a flash system rootfs.ext2
 
+WiFi
+====
+

Maybe add a little bit of text here. "To use the WiFi, you need to configure
your accesspoint first. Log in over the serial port, then type:"

board/amarula/a64-relic/readme.txt GPT: · line 66

Quoted 4 lines
board/amarula/a64-relic/readme.txt +4 -0
+ # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
+   (type password and enter)
+ # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
+ # udhcpc -i wlan0

Could we add the latter two to an init script instead? Should be S40 so it
coincides with S40network from ifupdown-scripts.

So in the readme, these two lines would then be replaced with

# /etc/init.d/S40wlan start

Quoted 11 lines
board/amarula/a64-relic/readme.txt +2 -0
+ # ping google.com
+
 Enjoy!
board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload new file +2 -0
new file mode 100755
index 0000000000..81d85ce01c
@@ -0,0 +1,12 @@
+#!/bin/sh
+#

board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload line 12

Quoted 10 lines
board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload new file +10 -0
+
+load_modules()
+{
+	while IFS= read -r line; do
+		modprobe -a $line
+	done < "/etc/modules-load.d/modules.conf"
+}
+
+load_modules
+echo "Loading modules: OK"

Init scripts should handle the start and stop arguments, otherwise the module
will be loaded again during shutdown.

Also, I don't think it makes a lot of sense to introduce all this flexibility.
Just include 'modprobe -a brcmfmac' to S40wlan.

Quoted 13 lines
board/amarula/a64-relic/rootfs_overlay/etc/modules-load.d/modules.conf new file +1 -0
new file mode 100644
index 0000000000..a86ef4c668
@@ -0,0 +1 @@
+brcmfmac
board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt new file +0 -0
new file mode 100644
index 0000000000..d095f24c26

board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt line 2

Quoted 2 lines
board/amarula/a64-relic/rootfs_overlay/lib/firmware/brcm/brcmfmac4330-sdio.txt new file +2 -0
@@ -0,0 +1,83 @@
+#AP6330_NVRAM_V1.0_20121130
+#Sample variables file for BCM94330 SD FC AGB board

Arg, these horrible brcm config files...

Regards,
Arnout

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH 2/2 board: amarula: a64-relic: Add WiFi support

Hello,

Quoted 11 lines · Arnout Vandecappelle
Quoted 4 lines

+ # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
+ (type password and enter)
+ # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
+ # udhcpc -i wlan0

Could we add the latter two to an init script instead? Should be S40 so it
coincides with S40network from ifupdown-scripts.

So in the readme, these two lines would then be replaced with

# /etc/init.d/S40wlan start

I'm not sure how that would work. You first need to enter the passphrase for the WiFi chip to associate with the AP, and therefore before doing the udhcp.

So when you suggest to replace the last two lines by "/etc/init.d/S40wlan start", how is this going to work considering that starting the S40wlan script has already been done at boot time ?

Quoted 13 lines

board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload line 12

Quoted 9 lines
board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload new file +9 -0
+load_modules()
+{
+	while IFS= read -r line; do
+		modprobe -a $line
+	done < "/etc/modules-load.d/modules.conf"
+}
+
+load_modules
+echo "Loading modules: OK"  

Init scripts should handle the start and stop arguments, otherwise the module
will be loaded again during shutdown.

Quoted 2 lines

Also, I don't think it makes a lot of sense to introduce all this flexibility.
Just include 'modprobe -a brcmfmac' to S40wlan.

Not directly related to Jagan's submission, but we do have this need to load modules at startup for a number of platforms. Isn't it time to have a generic init script that reads /etc/modules for this ? It's also a question that has been asked a number of times on IRC: "how do I ask my Buildroot system to load a kernel module at startup". Of course the answer is simple: add an init script, but since the question has been asked many times, perhaps it's worth adding some generic script ?

Or maybe in this case mdev support should be enabled to ensure modules are loaded automatically ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 2/2 board: amarula: a64-relic: Add WiFi support

Quoted 8 lines · Thomas Petazzoni

Hello,

Quoted 4 lines · Arnout Vandecappelle
Quoted 4 lines

+ # wpa_passphrase ACCESSPOINTNAME >> /etc/wpa_supplicant.conf
+ (type password and enter)
+ # wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
+ # udhcpc -i wlan0

I notice now that it was just copied from warp7 :-)

Quoted 8 lines
Quoted 7 lines

Could we add the latter two to an init script instead? Should be S40 so it
coincides with S40network from ifupdown-scripts.

So in the readme, these two lines would then be replaced with

# /etc/init.d/S40wlan start

Quoted 7 lines

I'm not sure how that would work. You first need to enter the passphrase for the WiFi chip to associate with the AP, and therefore before doing the udhcp.

So when you suggest to replace the last two lines by "/etc/init.d/S40wlan start", how is this going to work considering that starting the S40wlan script has already been done at boot time ?

If no ssid/password is configured, wpa_supplicant will just not connect, it
will just run as daemon. Same for udhcpc, it will just retry until the interface is up.

But you're right: it should be restart instead of start, so that the running
wpa_supplicant and udhcpc are killed before restarting them.

Quoted 16 lines
Quoted 13 lines

board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload line 12

Quoted 9 lines
board/amarula/a64-relic/rootfs_overlay/etc/init.d/S02-modload new file +9 -0
+load_modules()
+{
+	while IFS= read -r line; do
+		modprobe -a $line
+	done < "/etc/modules-load.d/modules.conf"
+}
+
+load_modules
+echo "Loading modules: OK"  

Init scripts should handle the start and stop arguments, otherwise the module
will be loaded again during shutdown.

Quoted 2 lines

Also, I don't think it makes a lot of sense to introduce all this flexibility.
Just include 'modprobe -a brcmfmac' to S40wlan.

Quoted 7 lines

Not directly related to Jagan's submission, but we do have this need to load modules at startup for a number of platforms. Isn't it time to have a generic init script that reads /etc/modules for this ? It's also a question that has been asked a number of times on IRC: "how do I ask my Buildroot system to load a kernel module at startup". Of course the answer is simple: add an init script, but since the question has been asked many times, perhaps it's worth adding some generic script ?

Yes indeed. Perhaps a separate package like ifupdown-scripts. It should
probably depend on !UDEV.

This could also be used for arcturus then.

Quoted 2 lines

Or maybe in this case mdev support should be enabled to ensure modules are loaded automatically ?

Probably, yes, since in most cases you need firmware as well. Actually, good
point: isn't mdev needed anyway to load the firmware? Oh, right, the kernel will autoload since 4.something so all the defconfigs we have that add mdev "For automatic firmware loading" are actually wrong...

But yes, mdev is probably the easier way.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#5 lore raw

PATCH 1/2 board: amarula: Add A64-Relic support

In reply to Jagan Teki

Hi Jagan,

A few loose remarks, not a full review...

On 28-05-18 19:12, Jagan Teki wrote:
[snip]

board/amarula/a64-relic/genimage.cfg line 26

Quoted 5 lines
board/amarula/a64-relic/genimage.cfg new file +5 -0
+	partition u-boot {
+		in-partition-table = "no"
+		image = "u-boot.itb"
+		offset = 40K
+		size = 1M # 1MB - 40K

What is it, 1M or 1M - 40K?

Anyway, I think it's better to remove size, and instead put offset in the first
real partition. I *think* genimage will complain if the image overflows over that offset.

Quoted 7 lines
board/amarula/a64-relic/genimage.cfg new file +7 -0
+	}
+
+	partition boot {
+		partition-type = 0xC
+		bootable = "true"
+		image = "boot.vfat"
+	}

[snip]

board/amarula/a64-relic/readme.txt line 4

Quoted 6 lines

+++ b/board/amarula/a64-relic/readme.txt

board/amarula/a64-relic/readme.txt new file +4 -0
@@ -0,0 +1,60 @@
+Amarula A64 Relic
+================
+
+Amarula A64-Relic is A64 based IoT device, which support

contains

Quoted 15 lines
board/amarula/a64-relic/readme.txt new file +15 -0
+- Allwinner A64 Cortex-A53
+- Mali-400MP2 GPU
+- AXP803 PMIC
+- 1GB DDR3 RAM
+- 8GB eMMC
+- AP6330 Wifi/BLE
+- MIPI-DSI
+- CSI: OV5640 sensor
+- USB OTG
+- 12V DC power supply
+
+Build
+=====
+
+  $ make amarula_a64_relic_defconfig

board/amarula/a64-relic/readme.txt line 29

Quoted 10 lines
board/amarula/a64-relic/readme.txt new file +10 -0
+
+  $ make
+
+build files at output/images/:
+  - sunxi-spl.bin
+  - u-boot.itb
+  - Image
+  - sun50i-a64-amarula-relic.dtb
+  - boot.vfat
+  - rootfs.ext2

ext4

board/amarula/a64-relic/readme.txt line 35

Quoted 6 lines
board/amarula/a64-relic/readme.txt new file +6 -0
+  - sdcard.img
+
+Write eMMC
+=========
+
+Open minicom with ttyUSBx with 115200N8 and power-on board.

You may want to start with a sentence "Connect the board with USB to the host."
And maybe even before that: "The board comes with an operating system preloaded on the eMMC. To replace it with the Buildroot-built system, take the following steps."

Review line 37

Quoted 2 lines
(quoted diff) +2 -0
+
+Stay in U-Boot and write images on eMMC

Maybe add how to stay in U-Boot: "Interrupt U-Boot by pressing enter."

Review line 39

Quoted 2 lines
(quoted diff) +2 -0
+
+DOS:

I guess you mean "To create an MBR partition table on the eMMC:"

Quoted 6 lines
board/amarula/a64-relic/readme.txt new file +6 -0
+
+  => mmc dev 1
+  => ums 0 mmc 1
+
+  host
+  $ dd if=sdcard.img of=/dev/sdx

board/amarula/a64-relic/readme.txt line 55

Quoted 10 lines
board/amarula/a64-relic/readme.txt new file +10 -0
+  $ sync
+
+GPT:
+
+  => mmc dev 1
+  => gpt write mmc 1 $partitions
+  => fastboot 0
+
+  host
+  $ fastboot -i 0x1f3a flash loader1 spl/sunxi-spl.bin

Are you sure about the spl/ part? If yes, it's wrong in the list of images above.

Also, better specify that you have to cd to output/images first.

board/amarula/a64-relic/readme.txt line 58

Quoted 3 lines
board/amarula/a64-relic/readme.txt new file +3 -0
+  $ fastboot -i 0x1f3a flash loader2 u-boot.itb
+  $ fastboot -i 0x1f3a flash esp boot.vfat
+  $ fastboot -i 0x1f3a flash system rootfs.ext2

ext4.

board/amarula/a64-relic/uboot.fragment line 2

Quoted 10 lines
(quoted diff) +2 -0
+
+Enjoy!
board/amarula/a64-relic/uboot.fragment new file +2 -0
new file mode 100644
index 0000000000..7b204598bc
@@ -0,0 +1,3 @@
+# A64-Relic need few user-defined configs enable on top of
+# uboot mainline default defconfig

This comment is not very useful IMO. Especially since you're not using mainline
U-Boot, you're using the amarula fork.

Regards,
Arnout

Quoted 1 line
board/amarula/a64-relic/uboot.fragment new file +1 -0
+CONFIG_CMD_USB_MASS_STORAGE=y

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF