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

Draft: Update to RTEMS 6 #55

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
device-tree-compiler \
u-boot-tools \
lzop \
libgmp3-dev \
libmpfr-dev \
libusb-1.0-0-dev \
python3 \
python-is-python3 \
Expand All @@ -46,6 +48,13 @@ jobs:
- name: Build toolchain
shell: bash
run: |
# Hack: Downloading gmp often fails on github. Seems that the server
# is rate limited or something like that. So pre-fetch the file from a
# mirror.
make submodule-update
mkdir external/rtems-source-builder/rtems/sources
wget -O external/rtems-source-builder/rtems/sources/gmp-6.3.0.tar.bz2 https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.bz2
# Hack end
make install
if [ "$RUNNER_OS" == "Linux" ]; then
make barebox
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/external/fdt/*.tar.gz
/fdt/b-dtb
/rtems/5
/rtems/6
build
/demo*/b-*/
external/libinih/b-imx7
Expand Down
76 changes: 28 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MAKEFILE_DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
ARCH = arm
BSP = imx7
BSP_GRISP1 = atsamv
RTEMS_VERSION = 5
RTEMS_VERSION = 6
TARGET = $(ARCH)-rtems$(RTEMS_VERSION)
PREFIX = $(MAKEFILE_DIR)/rtems/$(RTEMS_VERSION)
RSB = $(MAKEFILE_DIR)/external/rtems-source-builder
Expand Down Expand Up @@ -83,28 +83,38 @@ help:

.PHONY: install
#H Build and install the complete toolchain, libraries, fdt and so on.
install: submodule-update toolchain toolchain-revision bootstrap bsp bsp-grisp1 libbsd fdt bsp.mk libgrisp libinih cryptoauthlib barebox-install blas
install: submodule-update toolchain toolchain-revision bsp libbsd fdt bsp.mk libgrisp libinih cryptoauthlib barebox-install blas

.PHONY: submodule-update
#H Update the submodules.
submodule-update:
git submodule update --init
cd $(SRC_LIBBSD) && git submodule update --init rtems_waf

.PHONY: bootstrap
#H Run bootstrap for RTEMS.
bootstrap:
cd $(SRC_RTEMS) && $(RSB)/source-builder/sb-bootstrap

.PHONY: toolchain
#H Build and install the toolchain.
toolchain:
mkdir -p $(BUILD_LOGS)
rm -rf $(RSB)/rtems/build
# Downloading sometimes fails on the first try. So start with
# downloading twice
cd $(RSB)/rtems && ../source-builder/sb-set-builder \
--source-only-download \
--prefix=$(PREFIX) \
--log=$(BUILD_LOGS)/rsb-toolchain.log \
--with-fortran \
$(RTEMS_VERSION)/rtems-$(ARCH) || true
cd $(RSB)/rtems && ../source-builder/sb-set-builder \
--source-only-download \
--prefix=$(PREFIX) \
--log=$(BUILD_LOGS)/rsb-toolchain.log \
--with-fortran \
--with-fortran \
$(RTEMS_VERSION)/rtems-$(ARCH)
# Now build the tools
cd $(RSB)/rtems && ../source-builder/sb-set-builder \
--prefix=$(PREFIX) \
--log=$(BUILD_LOGS)/rsb-toolchain.log \
--with-fortran \
$(RTEMS_VERSION)/rtems-$(ARCH)
rm -rf $(RSB)/rtems/build

Expand All @@ -124,46 +134,16 @@ toolchain-revision:
.PHONY: bsp
#H Build the RTEMS board support package.
bsp:
rm -rf $(BUILD_BSP)
mkdir -p $(BUILD_BSP)
cd $(BUILD_BSP) && $(SRC_RTEMS)/configure \
--target=$(ARCH)-rtems$(RTEMS_VERSION) \
--prefix=$(PREFIX) \
--enable-posix \
--enable-rtemsbsp=$(BSP) \
--enable-maintainer-mode \
--disable-networking \
$(EXTRA_BSP_OPTS) \
IMX_CCM_IPG_HZ=66000000 \
IMX_CCM_UART_HZ=80000000 \
IMX_CCM_AHB_HZ=66000000 \
IMX_CCM_SDHCI_HZ=198000000 \
IMX_CCM_ECSPI_HZ=60000000
cd $(BUILD_BSP) && make -j $(NUMCORE)
cd $(BUILD_BSP) && make -j $(NUMCORE) install

.PHONY: bsp-grisp1
#H Build the RTEMS board support package for GRiSP1.
bsp-grisp1:
rm -rf $(BUILD_BSP_GRISP1)
mkdir -p $(BUILD_BSP_GRISP1)
cd $(BUILD_BSP_GRISP1) && $(SRC_RTEMS)/configure \
--target=$(ARCH)-rtems$(RTEMS_VERSION) \
--prefix=$(PREFIX) \
--enable-posix \
--enable-rtemsbsp=$(BSP_GRISP1) \
--enable-maintainer-mode \
--disable-networking \
--disable-tests \
$(EXTRA_BSP_OPTS) \
--enable-chip=same70q21 \
--enable-sdram=is42s16320f-7bl \
ATSAM_CONSOLE_DEVICE_TYPE=1 \
ATSAM_CONSOLE_DEVICE_INDEX=2 \
ATSAM_MEMORY_QSPIFLASH_SIZE=0x0 \
ATSAM_MEMORY_NOCACHE_SIZE=0x8000
cd $(BUILD_BSP_GRISP1) && make -j $(NUMCORE)
cd $(BUILD_BSP_GRISP1) && make -j $(NUMCORE) install
cd $(SRC_RTEMS) && ./waf clean || true
cp src/config.ini $(SRC_RTEMS)
if [ "$(DEBUG)" == "1" ]; then cd $(SRC_RTEMS) && sed -i \
-e "s|OPTIMIZATION_FLAGS = -O2|OPTIMIZATION_FLAGS = -O0|g" \
-e "s|RTEMS_DEBUG = False|RTEMS_DEBUG = True|g" \
config.ini; \
fi
cd $(SRC_RTEMS) && ./waf configure --prefix=$(PREFIX)
cd $(SRC_RTEMS) && ./waf
cd $(SRC_RTEMS) && ./waf install

.PHONY: bsp.mk
#H Build a Makefile helper for the applications.
Expand Down
2 changes: 1 addition & 1 deletion demo/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAKEFILE_DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
RTEMS_ROOT ?= $(MAKEFILE_DIR)/../rtems/5
RTEMS_ROOT ?= $(MAKEFILE_DIR)/../rtems/6
RTEMS_BSP ?= imx7

include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).mk
Expand Down
70 changes: 59 additions & 11 deletions demo/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/

#undef EVENT_RECORDING
#define RTC_ENABLED

#include <assert.h>
#include <stdlib.h>
Expand All @@ -45,6 +46,10 @@
#include <rtems/stringto.h>
#include <rtems/ftpd.h>
#include <machine/rtems-bsd-commands.h>
#ifdef RTC_ENABLED
#include <libchip/rtc.h>
#include <libchip/mcp7940m-rtc.h>
#endif
#ifdef EVENT_RECORDING
#include <rtems/record.h>
#include <rtems/recordserver.h>
Expand All @@ -57,6 +62,7 @@
#define IS_GRISP2 1
#endif

#include <grisp.h>
#ifdef IS_GRISP1
#include <bsp/i2c.h>
#include <grisp/pin-config.h>
Expand All @@ -69,6 +75,7 @@
#include "sd-card-test.h"
#include "1wire.h"
#include "pmod_rfid.h"
#include "pmod_dio.h"

#define STACK_SIZE_INIT_TASK (64 * 1024)
#define STACK_SIZE_SHELL (64 * 1024)
Expand All @@ -79,7 +86,6 @@
#define PRIO_WPA (RTEMS_MAXIMUM_PRIORITY - 1)

#define SPI_FDT_NAME "spi0"
#define SPI_BUS "/dev/spibus"

#define CMD_SPI_MAX_LEN 32

Expand Down Expand Up @@ -249,16 +255,36 @@ Init(rtems_task_argument arg)
assert(rv == 0);
#endif
#ifdef IS_GRISP2
rv = spi_bus_register_imx(SPI_BUS, SPI_FDT_NAME);
assert(rv == 0);
if (grisp_is_industrialgrisp()) {
/* Industrial GRiSP */
rv = spi_bus_register_imx(GRISP_SPI_DEVICE,
GRISP_INDUSTRIAL_SPI_ONBOARD_FDT_ALIAS);
assert(rv == 0);
rv = spi_bus_register_imx(GRISP_SPI_DEVICE "-pmod",
GRISP_INDUSTRIAL_SPI_PMOD_FDT_ALIAS);
assert(rv == 0);

rv = i2c_bus_register_imx(GRISP_I2C0_DEVICE,
GRISP_INDUSTRIAL_I2C_FDT_ALIAS);
assert(rv == 0);
} else {
/* GRiSP2 */
rv = spi_bus_register_imx(GRISP_SPI_DEVICE,
GRISP_SPI_FDT_ALIAS);
assert(rv == 0);

rv = i2c_bus_register_imx("/dev/i2c-1", "i2c0");
assert(rv == 0);
rv = i2c_bus_register_imx("/dev/i2c-1", "i2c0");
assert(rv == 0);

rv = i2c_bus_register_imx("/dev/i2c-2", "i2c1");
assert(rv == 0);
rv = i2c_bus_register_imx("/dev/i2c-2", "i2c1");
assert(rv == 0);
}
#endif /* IS_GRISP2 */

#ifdef RTC_ENABLED
setRealTimeToRTEMS();
#endif

printf("Init EEPROM\n");
grisp_eeprom_init();
rv = grisp_eeprom_get(&eeprom);
Expand Down Expand Up @@ -289,8 +315,11 @@ Init(rtems_task_argument arg)
grisp_init_dhcpcd(PRIO_DHCP);

grisp_led_set2(false, false, true);
sleep(3);
grisp_init_wpa_supplicant(wpa_supplicant_conf, PRIO_WPA, create_wlandev);
if (!grisp_is_industrialgrisp()) {
sleep(3);
grisp_init_wpa_supplicant(wpa_supplicant_conf, PRIO_WPA,
create_wlandev);
}

#ifdef EVENT_RECORDING
rtems_record_start_server(10, 1234, 10);
Expand All @@ -299,14 +328,30 @@ Init(rtems_task_argument arg)

init_led();
#ifdef IS_GRISP2
// uncomment for testing RFID
//pmod_rfid_init(SPI_BUS, 1);
if (grisp_is_industrialgrisp()) {
pmod_rfid_init(GRISP_SPI_DEVICE, 0);
pmod_dio_init(GRISP_SPI_DEVICE);
} else {
// uncomment for testing RFID
//pmod_rfid_init(GRISP_SPI_DEVICE, 1);
}
#endif /* IS_GRISP2 */
start_shell();

exit(0);
}

#ifdef RTC_ENABLED
static struct mcp7940m_rtc rtc_ctx =
MCP7940M_RTC_INITIALIZER("/dev/i2c-1", 0x6f, false);

rtc_tbl RTC_Table[] = {
MCP7940M_RTC_TBL_ENTRY("/dev/rtc", &rtc_ctx),
};

size_t RTC_Count = (sizeof(RTC_Table)/sizeof(rtc_tbl));
#endif

/*
* Configure LibBSD.
*/
Expand All @@ -321,6 +366,9 @@ Init(rtems_task_argument arg)
*/
#define CONFIGURE_MICROSECONDS_PER_TICK 10000

#ifdef RTC_ENABLED
#define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
#endif
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
Expand Down
Loading
Loading