Add 96Boards Nitrogen support
v2 cover Add 96Boards Nitrogen support
From: Wojciech Zmuda <[email protected]>
Hello,
v1 -> v2:
- README.txt: fix bad MACHINE examples: change _ to -, i.e. 96b_nitrogen -> 96b-nitrogen
This patch set adds support for the Nitrogen board by 96Boards. The support consists of:
- adding configs for Cortex-M4, nRF52832 SoC and Nitrogen board,
- adding bbclass with pyocd-based do_flash_usb() implementation.
Tested on Nitrogen and on QEMU so I hope I didn't accidentally break anything.
Verification:
1. Install pyocd.
2. Connect Nitrogen and make sure you can see Bus 001 Device 004: ID 0d28:0204 NXP ARM mbed in lsusb.
3. Build a sample app:
$ MACHINE=96b-nitrogen DISTRO=zephyr bitbake zephyr-philosophers
4. Flash app to the board:
$ MACHINE=96b-nitrogen DISTRO=zephyr bitbake zephyr-philosophers -c flash_usbWojciech Zmuda (5):
zephyr-kernel: clone Nordic HAL
conf: machine: add support for Nordic nRF52832 Cortex-M4 chip
conf: machine: add 96boards Nitrogen support
zephyr-kernel: don't limit deploy to .elf file zephyr-flash-pyocd.bbclass: support for flashing via pyocd
README.txt | 23 +++++++++++++++++++ classes/zephyr-flash-pyocd.bbclass | 17 ++++++++++++++ classes/zephyr-kernel-src.bbclass | 7 +++--- conf/machine/96b-nitrogen.conf | 8 +++++++ conf/machine/include/nrf52832.inc | 10 ++++++++ conf/machine/include/tune-cortexm4.inc | 19 +++++++++++++++ .../zephyr-kernel/zephyr-helloworld.bb | 3 ++- recipes-kernel/zephyr-kernel/zephyr-image.inc | 2 +- .../zephyr-kernel/zephyr-kernel-common.inc | 5 +++- .../zephyr-kernel/zephyr-philosophers.bb | 3 ++- 10 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 classes/zephyr-flash-pyocd.bbclass create mode 100644 conf/machine/96b-nitrogen.conf create mode 100644 conf/machine/include/nrf52832.inc create mode 100644 conf/machine/include/tune-cortexm4.inc
Signature · 1 line
2.25.1
PATCH v2 1/5 zephyr-kernel: clone Nordic HAL
From: Wojciech Zmuda <[email protected]>
HAL for Nordic chipsets is one of Zephyr subprojects. It is downloaded by default by west. Clone the HAL repository so it can be used for building images for boards with Nordic chips.
--- classes/zephyr-kernel-src.bbclass | 7 ++++--- recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc | 1 + 2 files changed, 5 insertions(+), 3 deletions(-)
classes/zephyr-kernel-src.bbclass +4 -3
@@ -5,12 +5,13 @@ PREFERRED_VERSION_zephyr-kernel ??= "2.4.0" SRCREV_FORMAT = "default_cmsis" SRCREV_default = "7a3b253ced7333f5c0269387a7f3ed1dee69739d" SRCREV_cmsis = "542b2296e6d515b265e25c6b7208e8fea3014f90" - +SRCREV_nordic = "d8a6ea9695ddf792bb18bb6035c13b1daac5d79c" SRC_URI = "git://github.com/zephyrproject-rtos/zephyr.git;protocol=https;branch=v2.4-branch;name=default \ git://github.com/zephyrproject-rtos/cmsis.git;protocol=https;destsuffix=git/modules/cmsis;name=cmsis \ - file://0001-cmake-add-yocto-toolchain.patch \ - " + git://github.com/zephyrproject-rtos/hal_nordic.git;protocol=https;destsuffix=git/modules/hal/nordic;name=nordic \ + file://0001-cmake-add-yocto-toolchain.patch \ + " PV = "2.4.0+git${SRCPV}"
recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc +1 -0
@@ -16,6 +16,7 @@ ZEPHYR_MAKE_OUTPUT = "zephyr.elf" EXTRA_OECMAKE = " -DZEPHYR_BASE=${S} -DZEPHYR_GCC_VARIANT=yocto -DBOARD=${BOARD} -DARCH=${ARCH} -DCROSS_COMPILE=${CROSS_COMPILE} -DZEPHYR_SYSROOT=${ZEPHYR_SYSROOT} -DZEPHYR_TOOLCHAIN_VARIANT=yocto" EXTRA_OECMAKE_append_arm = " -DZEPHYR_MODULES=${S}/modules/cmsis" +EXTRA_OECMAKE_append_nordic = "\;${S}/modules/hal/nordic" export ZEPHYR_BASE="${S}"
Signature · 1 line
2.25.1
PATCH v2 2/5 conf: machine: add support for Nordic nRF52832 Cortex-M4 chip
In reply to Wojciech ZmudaFrom: Wojciech Zmuda <[email protected]>
Add include for Cortex-M4 tunes and nRF52832. The nRF config appends 'nordic' to MACHINEOVERRIDES, so the kernel recipe can include Nordic HAL when this override is detected.
--- conf/machine/include/nrf52832.inc | 10 ++++++++++ conf/machine/include/tune-cortexm4.inc | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 conf/machine/include/nrf52832.inc create mode 100644 conf/machine/include/tune-cortexm4.inc
conf/machine/include/nrf52832.inc new file +10 -0
@@ -0,0 +1,10 @@ +#@TYPE: Machine +#@NAME: nrf52832 + +#@DESCRIPTION: Machine configuration for Nordic Semiconductor nRF52832 (Cortex-M4) SoC. + +require conf/machine/include/tune-cortexm4.inc + +MACHINEOVERRIDES =. "nordic:" + +TUNE_FEATURES = "armv7m cortexm4"
conf/machine/include/tune-cortexm4.inc new file +19 -0
@@ -0,0 +1,19 @@ +DEFAULTTUNE ?= "cortexm4" + +require conf/machine/include/arm/arch-armv7a.inc + +TUNEVALID[cortexm4] = "Enable Cortex-M4 specific processor optimizations" +TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm4', ' -mcpu=cortex-m4', '', d)}" +AVAILTUNES += "cortexm4" + +TUNEVALID[armv7m] = "Enable Cortex-M4 specific processor optimizations" +TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'armv7m', ' -march=armv7e-m', '', d)}" +MACHINEOVERRIDES =. "${@bb.utils.contains('TUNE_FEATURES', 'armv7m', 'armv7m:', '' ,d)}" + +TUNE_PKGARCH_tune-cortexm4 = "cortexm4" + +ARMPKGARCH_tune-cortexm4 = "armv7m" +PACKAGE_EXTRA_ARCHS_tune-cortexm4 ="cortexm4" + +TUNE_FEATURES_tune-cortexm4 = "armv7m vfp cortexm4" +PACKAGE_EXTRA_ARCHS_tune-cortexm4 = "${PACKAGE_EXTRA_ARCHS_tune-armv7at} armv7m-vfp armv7m"
Signature · 1 line
2.25.1
PATCH v2 3/5 conf: machine: add 96boards Nitrogen support
In reply to Wojciech ZmudaFrom: Wojciech Zmuda <[email protected]>
The board is based on Nordic nRF52832 Cortex-M4 chip. The support depends on Nordic HAL. It has been verified with zephyr-philosophers and zephyr-shell sample applications.
--- conf/machine/96b-nitrogen.conf | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 conf/machine/96b-nitrogen.conf
conf/machine/96b-nitrogen.conf new file +7 -0
@@ -0,0 +1,7 @@ +#@TYPE: Machine +#@NAME: 96b_nitrogen + +#@DESCRIPTION: Machine configuration for 96Boards Nitrogen Board. + +require conf/machine/include/nrf52832.inc +ARCH_96b-nitrogen = "arm"
Signature · 1 line
2.25.1
PATCH v2 4/5 zephyr-kernel: don't limit deploy to .elf file
In reply to Wojciech ZmudaFrom: Wojciech Zmuda <[email protected]>
Depending on the target board and/or flashing method, it may be desirable to have access to .bin or .hex files instead of .elf. Remove .elf extension from ZEPHYR_MAKE_OUTPUT and let users of that variable specify the extension.
Append .elf to all identified users, since they worked with .elf so far.
--- recipes-kernel/zephyr-kernel/zephyr-helloworld.bb | 2 +- recipes-kernel/zephyr-kernel/zephyr-image.inc | 2 +- recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc | 4 +++- recipes-kernel/zephyr-kernel/zephyr-philosophers.bb | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-)
recipes-kernel/zephyr-kernel/zephyr-helloworld.bb +1 -1
@@ -7,7 +7,7 @@ ZEPHYR_BASE = "${S}" OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}" do_deploy () { - install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${PN}.elf + install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf } addtask deploy after do_compile
recipes-kernel/zephyr-kernel/zephyr-image.inc +1 -1
@@ -10,7 +10,7 @@ ZEPHYR_BASE = "${S}" OECMAKE_SOURCEPATH = "${S}/${ZEPHYR_SRC_DIR}" do_deploy () { - install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${ZEPHYR_IMAGENAME} + install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${ZEPHYR_IMAGENAME} } addtask deploy after do_compile
recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc +3 -1
@@ -11,7 +11,9 @@ IMAGE_NO_MANIFEST = "1" ZEPHYR_GCC_VARIANT="yocto" ZEPHYR_SYSROOT="${STAGING_DIR_TARGET}" -ZEPHYR_MAKE_OUTPUT = "zephyr.elf" +# Output image name. There are several variants i.e. .bin, .elf, .hex. +# Let the user append desired suffix. +ZEPHYR_MAKE_OUTPUT = "zephyr" EXTRA_OECMAKE = " -DZEPHYR_BASE=${S} -DZEPHYR_GCC_VARIANT=yocto -DBOARD=${BOARD} -DARCH=${ARCH} -DCROSS_COMPILE=${CROSS_COMPILE} -DZEPHYR_SYSROOT=${ZEPHYR_SYSROOT} -DZEPHYR_TOOLCHAIN_VARIANT=yocto"
recipes-kernel/zephyr-kernel/zephyr-philosophers.bb +1 -1
@@ -7,7 +7,7 @@ ZEPHYR_BASE = "${S}" OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}" do_deploy () { - install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${PN}.elf + install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf } addtask deploy after do_compile
Signature · 1 line
2.25.1
PATCH v2 5/5 zephyr-flash-pyocd.bbclass: support for flashing via pyocd
In reply to Wojciech ZmudaFrom: Wojciech Zmuda <[email protected]>
Flash boards supported via pyocd:
MACHINE=xxx bitbake yyy -c flash_usb
The only supported board for now is 96Boards Nitrogen. Modify its config accordingly.
Modify helloworld and philosopers samples with adidtional .hex output file deployment, as this format is required by pyocd.
Describe the feature in README.
--- README.txt | 23 +++++++++++++++++++ classes/zephyr-flash-pyocd.bbclass | 17 ++++++++++++++ conf/machine/96b-nitrogen.conf | 1 + .../zephyr-kernel/zephyr-helloworld.bb | 1 + .../zephyr-kernel/zephyr-philosophers.bb | 1 + 5 files changed, 43 insertions(+) create mode 100644 classes/zephyr-flash-pyocd.bbclass
README.txt +23 -0
@@ -43,6 +43,29 @@ The same sample, for Nios2 image: $ MACHINE=qemu-nios2 bitbake zephyr-philosophers $ runqemu qemu-nios2 +Flashing +================================= + +You can flash Zephyr samples to boards. Currently, the following MACHINEs +are supported: + * DFU: + - arduino-101-sss + - arduino-101 + - arduino-101-ble + * pyocd: + - 96b-nitrogen + +To flash the example you built with command e.g. + + $ MACHINE=96b-nitrogen bitbake zephyr-philosophers + +call similar command with explicit flash_usb command: + + $ MACHINE=96b-nitrogen bitbake zephyr-philosophers -c flash_usb + +dfu-util and/or pyocd need to be installed in your system. If you observe +permission errors or the flashing process seem to hang, follow those instructions: +https://github.com/pyocd/pyOCD/tree/master/udev Building and Running Zephyr Tests =================================
classes/zephyr-flash-pyocd.bbclass new file +17 -0
@@ -0,0 +1,17 @@ + +python do_flash_usb() { + from pyocd.core.helpers import ConnectHelper + from pyocd.flash.file_programmer import FileProgrammer + + image = f"{d.getVar('DEPLOY_DIR_IMAGE')}/{d.getVar('PN')}.hex" + bb.plain(f"Attempting to flash {image} to board {d.getVar('BOARD')}") + + with ConnectHelper.session_with_chosen_probe() as session: + FileProgrammer(session).program(image) + session.board.target.reset() +} + +addtask do_flash_usb + +do_flash_usb[nostamp] = "1" +do_flash_usb[vardepsexclude] = "BB_ORIGENV"
conf/machine/96b-nitrogen.conf +1 -0
@@ -4,4 +4,5 @@ #@DESCRIPTION: Machine configuration for 96Boards Nitrogen Board. require conf/machine/include/nrf52832.inc +ZEPHYR_INHERIT_CLASSES += "zephyr-flash-pyocd" ARCH_96b-nitrogen = "arm"
recipes-kernel/zephyr-kernel/zephyr-helloworld.bb +1 -0
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}" do_deploy () { install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf + install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex ${DEPLOYDIR}/${PN}.hex } addtask deploy after do_compile
recipes-kernel/zephyr-kernel/zephyr-philosophers.bb +1 -0
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}" do_deploy () { install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf + install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex ${DEPLOYDIR}/${PN}.hex } addtask deploy after do_compile
Signature · 1 line
2.25.1