Skip to content

Commit

Permalink
Merge pull request #400 from hansemro/add-ht32-boards
Browse files Browse the repository at this point in the history
Add/update HT32F165X  and HT32F523X2 boards and linker scripts
  • Loading branch information
fpoussin authored Jun 1, 2024
2 parents 86e74c0 + 8a560ac commit e7dd416
Show file tree
Hide file tree
Showing 14 changed files with 2,537 additions and 4 deletions.
93 changes: 93 additions & 0 deletions os/common/startup/ARMCMx/compilers/GCC/ld/HT32F1655.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (C) Yaotian Feng, http://github.com/Codetector1374
* [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


/*
* HT32F1655 memory setup
*/

MEMORY {
flash0 : org = 0x00000000, len = 128k
flash1 : org = 0x00000000, len = 0
flash2 : org = 0x00000000, len = 0
flash3 : org = 0x00000000, len = 0
flash4 : org = 0x00000000, len = 0
flash5 : org = 0x00000000, len = 0
flash6 : org = 0x00000000, len = 0
flash7 : org = 0x00000000, len = 0
ram0 : org = 0x20000000, len = 32k
ram1 : org = 0x00000000, len = 0
ram2 : org = 0x00000000, len = 0
ram3 : org = 0x00000000, len = 0
ram4 : org = 0x00000000, len = 0
ram5 : org = 0x00000000, len = 0
ram6 : org = 0x00000000, len = 0
ram7 : org = 0x00000000, len = 0
}

/* 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
93 changes: 93 additions & 0 deletions os/common/startup/ARMCMx/compilers/GCC/ld/HT32F1656.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (C) Yaotian Feng, http://github.com/Codetector1374
* [email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


/*
* HT32F1656 memory setup
*/

MEMORY {
flash0 : org = 0x00000000, len = 255k
flash1 : org = 0x00000000, len = 0
flash2 : org = 0x00000000, len = 0
flash3 : org = 0x00000000, len = 0
flash4 : org = 0x00000000, len = 0
flash5 : org = 0x00000000, len = 0
flash6 : org = 0x00000000, len = 0
flash7 : org = 0x00000000, len = 0
ram0 : org = 0x20000000, len = 32k
ram1 : org = 0x00000000, len = 0
ram2 : org = 0x00000000, len = 0
ram3 : org = 0x00000000, len = 0
ram4 : org = 0x00000000, len = 0
ram5 : org = 0x00000000, len = 0
ram6 : org = 0x00000000, len = 0
ram7 : org = 0x00000000, len = 0
}

/* 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/*
* HT32F5234x memory setup
* HT32F52342 memory setup
*/

MEMORY {
Expand Down Expand Up @@ -93,7 +93,7 @@ REGION_ALIAS("HEAP_RAM", ram0);
INCLUDE rules_stacks.ld

/* Code rules inclusion.*/
INCLUDE HT32F523xx_rules_code.ld
INCLUDE HT32F523x2_rules_code.ld

/* Data rules inclusion.*/
INCLUDE rules_data.ld
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/*
* HT32F5235x memory setup
* HT32F52352 memory setup
*/

MEMORY {
Expand Down Expand Up @@ -93,7 +93,7 @@ REGION_ALIAS("HEAP_RAM", ram0);
INCLUDE rules_stacks.ld

/* Code rules inclusion.*/
INCLUDE HT32F523xx_rules_code.ld
INCLUDE HT32F523x2_rules_code.ld

/* Data rules inclusion.*/
INCLUDE rules_data.ld
Expand Down
99 changes: 99 additions & 0 deletions os/hal/boards/HT_HT32F1653_4/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
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 PAL setup.
* @details Digital I/O ports static configuration as defined in @p board.h.
* This variable is used by the HAL when initializing the PAL driver.
*/
#if HAL_USE_PAL || defined(__DOXYGEN__)
const PALConfig pal_default_config = {
// GPIO A
.setup[0] =
{
.DIR = VAL_GPIOA_DIRCR,
.INE = VAL_GPIOA_INER,
.PU = VAL_GPIOA_PUR,
.PD = VAL_GPIOA_PDR,
.OD = VAL_GPIOA_ODR,
.DRV = VAL_GPIOA_DRVR,
.LOCK = 0x0000,
.OUT = 0x0000,
.CFG[0] = VAL_GPIOA_AFCFGR0,
.CFG[1] = VAL_GPIOA_AFCFGR1,
},
// GPIO B
.setup[1] =
{
.DIR = VAL_GPIOB_DIRCR,
.INE = VAL_GPIOB_INER,
.PU = VAL_GPIOB_PUR,
.PD = VAL_GPIOB_PDR,
.OD = VAL_GPIOB_ODR,
.DRV = VAL_GPIOB_DRVR,
.LOCK = 0x0000,
.OUT = 0x0000,
.CFG[0] = VAL_GPIOB_AFCFGR0,
.CFG[1] = VAL_GPIOB_AFCFGR1,
},
// GPIO C
.setup[2] =
{
.DIR = VAL_GPIOC_DIRCR,
.INE = VAL_GPIOC_INER,
.PU = VAL_GPIOC_PUR,
.PD = VAL_GPIOC_PDR,
.OD = VAL_GPIOC_ODR,
.DRV = VAL_GPIOC_DRVR,
.LOCK = 0x0000,
.OUT = 0x0000,
.CFG[0] = VAL_GPIOC_AFCFGR0,
.CFG[1] = VAL_GPIOC_AFCFGR1,
},
// GPIO D
.setup[3] =
{
.DIR = VAL_GPIOD_DIRCR,
.INE = VAL_GPIOD_INER,
.PU = VAL_GPIOD_PUR,
.PD = VAL_GPIOD_PDR,
.OD = VAL_GPIOD_ODR,
.DRV = VAL_GPIOD_DRVR,
.LOCK = 0x0000,
.OUT = 0x0000,
.CFG[0] = VAL_GPIOD_AFCFGR0,
.CFG[1] = VAL_GPIOD_AFCFGR1,
},
.ESSR[0] = VAL_ESSR0,
.ESSR[1] = VAL_ESSR1,
};
#endif

/*
* Early initialization code.
* This initialization must be performed just after stack setup and before
* any other initialization.
*/
void __early_init(void) {
ht32_clock_init();
}

/*
* Board-specific initialization code.
*/
void boardInit(void) {}
Loading

0 comments on commit e7dd416

Please sign in to comment.