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

Experimental NUC120 Support #264

Draft
wants to merge 15 commits into
base: chibios-21.11.x
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
102 changes: 102 additions & 0 deletions os/common/startup/ARMCMx/compilers/GCC/ld/NUC120xE3xx.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
Copyright (C) 2020 Alex Lewontin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
* NUC123xD4xx0 memory setup.
* 64k ROM, 20k ram
*/
MEMORY
{
flash0 (rx) : org = 0x00000000, len = 0x20000 /* APROM */
flash1 (rx) : org = 0x00000000, len = 0 /* Data flash placeholder */
flash2 (rx) : org = 0x00100000, len = 0x1000 /* LDROM */
flash3 (rx) : org = 0x00300000, len = 4 /* Config0 */
flash4 (rx) : org = 0x00300004, len = 4 /* Config1 */
flash5 (rx) : org = 0x00000000, len = 0
flash6 (rx) : org = 0x00000000, len = 0
flash7 (rx) : org = 0x00000000, len = 0
ram0 (wx) : org = 0x20000000, len = 0x4000
ram1 (wx) : org = 0x00000000, len = 0
ram2 (wx) : org = 0x00000000, len = 0
ram3 (wx) : org = 0x00000000, len = 0
ram4 (wx) : org = 0x00000000, len = 0
ram5 (wx) : org = 0x00000000, len = 0
ram6 (wx) : org = 0x00000000, len = 0
ram7 (wx) : org = 0x00000000, len = 0
}

REGION_ALIAS("CONFIG0", flash3);
REGION_ALIAS("CONFIG1", flash4);

SECTIONS
{
.nuc123_config0 : ALIGN(4)
{
KEEP(*(.nuc123_config0))
} > CONFIG0

.nuc123_config1 : ALIGN(4)
{
KEEP(*(.nuc123_config1))
} > CONFIG1
}

/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/

/* Flash region to be used for exception vectors.*/
REGION_ALIAS("VECTORS_FLASH", flash0);
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);

/* Flash region to be used for constructors and destructors.*/
REGION_ALIAS("XTORS_FLASH", flash0);
REGION_ALIAS("XTORS_FLASH_LMA", flash0);

/* Flash region to be used for code text.*/
REGION_ALIAS("TEXT_FLASH", flash0);
REGION_ALIAS("TEXT_FLASH_LMA", flash0);

/* Flash region to be used for read only data.*/
REGION_ALIAS("RODATA_FLASH", flash0);
REGION_ALIAS("RODATA_FLASH_LMA", flash0);

/* Flash region to be used for various.*/
REGION_ALIAS("VARIOUS_FLASH", flash0);
REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);

/* Flash region to be used for RAM(n) initialization data.*/
REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);

/* RAM region to be used for Main stack. This stack accommodates the processing
of all exceptions and interrupts.*/
REGION_ALIAS("MAIN_STACK_RAM", ram0);

/* RAM region to be used for the process stack. This is the stack used by
the main() function.*/
REGION_ALIAS("PROCESS_STACK_RAM", ram0);

/* RAM region to be used for data segment.*/
REGION_ALIAS("DATA_RAM", ram0);
REGION_ALIAS("DATA_RAM_LMA", flash0);

/* RAM region to be used for BSS segment.*/
REGION_ALIAS("BSS_RAM", ram0);

/* RAM region to be used for the default heap.*/
REGION_ALIAS("HEAP_RAM", ram0);

/* Generic rules inclusion.*/
INCLUDE rules.ld
28 changes: 22 additions & 6 deletions os/common/startup/ARMCMx/compilers/GCC/ld/NUC123xD4xx0.ld
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
*/
MEMORY
{
flash0 (rx) : org = 0x00000000, len = 64k
flash1 (rx) : org = 0x00000000, len = 0
flash2 (rx) : org = 0x00000000, len = 0
flash3 (rx) : org = 0x00000000, len = 0
flash4 (rx) : org = 0x00000000, len = 0
flash0 (rx) : org = 0x00000000, len = 0x11000 /* APROM */
flash1 (rx) : org = 0x00000000, len = 0 /* Data flash placeholder */
flash2 (rx) : org = 0x00100000, len = 0x1000 /* LDROM */
flash3 (rx) : org = 0x00300000, len = 4 /* Config0 */
flash4 (rx) : org = 0x00300004, len = 4 /* Config1 */
flash5 (rx) : org = 0x00000000, len = 0
flash6 (rx) : org = 0x00000000, len = 0
flash7 (rx) : org = 0x00000000, len = 0
ram0 (wx) : org = 0x20000000, len = 20k
ram0 (wx) : org = 0x20000000, len = 0x5000
ram1 (wx) : org = 0x00000000, len = 0
ram2 (wx) : org = 0x00000000, len = 0
ram3 (wx) : org = 0x00000000, len = 0
Expand All @@ -38,6 +38,22 @@ MEMORY
ram7 (wx) : org = 0x00000000, len = 0
}

REGION_ALIAS("CONFIG0", flash3);
REGION_ALIAS("CONFIG1", flash4);

SECTIONS
{
.nuc123_config0 : ALIGN(4)
{
KEEP(*(.nuc123_config0))
} > CONFIG0

.nuc123_config1 : ALIGN(4)
{
KEEP(*(.nuc123_config1))
} > CONFIG1
}

/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/

Expand Down
36 changes: 36 additions & 0 deletions os/hal/boards/NUTINY-SDK-NUC120-V1.0/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
ChibiOS - Copyright (C) 2020 Alex Lewontin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "hal.h"

/**
* @brief Board-specific initialization code.
*/
void boardInit(void)
{
#if HAL_USE_PAL
OnboardLED_Init();
#endif
}

/**
* @brief Early initialization code.
* @details This initialization is performed just after reset before BSS and
* DATA segments initialization.
*/
void __early_init(void)
{
}
60 changes: 60 additions & 0 deletions os/hal/boards/NUTINY-SDK-NUC120-V1.0/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
ChibiOS - Copyright (C) 2020 Alex Lewontin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef BOARD_H
#define BOARD_H

/*
* Setup for a generic board.
*/

/*
* Board identifier.
*/
#define NUC123SD4AN0
#define NUC120LE3AN
#define BOARD_NAME "NUTINY SDK NUC120 V1.0"

/*
* Board specific settings.
*/
/*
* External XTAL speed.
*/
#define NUC123_HSECLK 12000000UL

/*
* LED macros.
*/
#define ONBOARD_LED_LINE PAL_LINE(GPIOB, 0)

#define OnboardLED_Init() \
palSetGroupMode(GPIOB, 1, 0, PAL_MODE_OUTPUT_OPENDRAIN)
#define OnboardLED_On() palClearLine(ONBOARD_LED_LINE)
#define OnboardLED_Off() palSetLine(ONBOARD_LED_LINE)
#define OnboardLED_Toggle() palToggleLine(ONBOARD_LED_LINE)

#if !defined(_FROM_ASM_)
#ifdef __cplusplus
extern "C" {
#endif
void boardInit(void);
#ifdef __cplusplus
}
#endif
#endif /* _FROM_ASM_ */

#endif /* BOARD_H */
10 changes: 10 additions & 0 deletions os/hal/boards/NUTINY-SDK-NUC120-V1.0/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# List of all the board related files.
BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/NUTINY-SDK-NUC120-V1.0/board.c

# Required include directories
BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/NUTINY-SDK-NUC120-V1.0

LDSCRIPT= $(STARTUPLD_CONTRIB)/NUC120xE3xx.ld

ALLCSRC += $(BOARDSRC)
ALLINC += $(BOARDINC)
9 changes: 9 additions & 0 deletions os/hal/ports/NUMICRO/LLD/FLASHv1/driver.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ifeq ($(USE_SMART_BUILD),yes)
ifneq ($(findstring HAL_USE_EFL TRUE,$(HALCONF)),)
PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/NUMICRO/LLD/FLASHv1/hal_efl_lld.c
endif
else
PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/NUMICRO/LLD/FLASHv1/hal_efl_lld.c
endif

PLATFORMINC += $(CHIBIOS_CONTRIB)/os/hal/ports/NUMICRO/LLD/FLASHv1
Loading