Skip to content

Commit ed34a53

Browse files
author
Yannick Vignon
committed
MiniM4: initial commit of new target
Basic support for new Mini-M4 board. Work in progress, not working yet.
1 parent ab68825 commit ed34a53

35 files changed

+6686
-4
lines changed

flight/PiOS/STM32F4xx/pios_sys.c

+3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ void PIOS_SYS_Init(void)
163163
GPIO_Init(GPIOA, &GPIO_InitStructure);
164164

165165
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
166+
GPIO_InitStructure.GPIO_Pin &= ~(GPIO_Pin_3 | GPIO_Pin_4); // leave JTAG pins alone
166167
GPIO_Init(GPIOB, &GPIO_InitStructure);
168+
169+
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
167170
GPIO_Init(GPIOC, &GPIO_InitStructure);
168171
GPIO_Init(GPIOD, &GPIO_InitStructure);
169172
GPIO_Init(GPIOE, &GPIO_InitStructure);

flight/targets/minim4/bl/pios_board.c

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
******************************************************************************
3+
* @addtogroup TauLabsBootloader Tau Labs Bootloaders
4+
* @{
5+
* @addtogroup QuantonBL Quanton bootloader
6+
* @{
7+
*
8+
* @file pios_board.c
9+
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
10+
* @author Tau Labs, http://taulabs.org, Copyright (C) 2012-2013
11+
* @brief Board specific initialization for the bootloader
12+
* @see The GNU Public License (GPL) Version 3
13+
*
14+
*****************************************************************************/
15+
/*
16+
* This program is free software; you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation; either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* This program is distributed in the hope that it will be useful, but
22+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24+
* for more details.
25+
*
26+
* You should have received a copy of the GNU General Public License along
27+
* with this program; if not, write to the Free Software Foundation, Inc.,
28+
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29+
*/
30+
31+
/* Pull in the board-specific static HW definitions.
32+
* Including .c files is a bit ugly but this allows all of
33+
* the HW definitions to be const and static to limit their
34+
* scope.
35+
*
36+
* NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
37+
*/
38+
#include "board_hw_defs.c"
39+
40+
#include <pios_board_info.h>
41+
#include <pios.h>
42+
43+
uintptr_t pios_com_telem_usb_id;
44+
45+
void PIOS_Board_Init() {
46+
47+
/* Delay system */
48+
PIOS_DELAY_Init();
49+
50+
const struct pios_board_info * bdinfo = &pios_board_info_blob;
51+
52+
#if defined(PIOS_INCLUDE_LED)
53+
const struct pios_led_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
54+
PIOS_Assert(led_cfg);
55+
PIOS_LED_Init(led_cfg);
56+
#endif /* PIOS_INCLUDE_LED */
57+
58+
PWR_BackupAccessCmd(ENABLE);
59+
RCC_LSEConfig(RCC_LSE_OFF);
60+
61+
PIOS_LED_On(PIOS_LED_HEARTBEAT);
62+
PIOS_LED_On(PIOS_LED_ALARM);
63+
64+
#if defined(PIOS_INCLUDE_SPI)
65+
/* Set up the SPI interface to the flash */
66+
if (PIOS_SPI_Init(&pios_spi_flash_id, &pios_spi_flash_cfg)) {
67+
PIOS_DEBUG_Assert(0);
68+
}
69+
#endif /* PIOS_INCLUDE_SPI */
70+
71+
#if defined(PIOS_INCLUDE_FLASH)
72+
/* Inititialize all flash drivers */
73+
PIOS_Flash_Internal_Init(&pios_internal_flash_id, &flash_internal_cfg);
74+
75+
#if defined(PIOS_INCLUDE_SPI)
76+
PIOS_Flash_Jedec_Init(&pios_external_flash_id, pios_spi_flash_id, 0, &flash_mx25_cfg);
77+
#endif /* PIOS_INCLUDE_SPI */
78+
79+
/* Register the partition table */
80+
PIOS_FLASH_register_partition_table(pios_flash_partition_table, NELEMENTS(pios_flash_partition_table));
81+
#endif /* PIOS_INCLUDE_FLASH */
82+
83+
#if defined(PIOS_INCLUDE_USB)
84+
/* Initialize board specific USB data */
85+
PIOS_USB_BOARD_DATA_Init();
86+
87+
/* Activate the HID-only USB configuration */
88+
PIOS_USB_DESC_HID_ONLY_Init();
89+
90+
uintptr_t pios_usb_id;
91+
PIOS_USB_Init(&pios_usb_id, PIOS_BOARD_HW_DEFS_GetUsbCfg(bdinfo->board_rev));
92+
93+
#if defined(PIOS_INCLUDE_USB_HID) && defined(PIOS_INCLUDE_COM_MSG)
94+
uintptr_t pios_usb_hid_id;
95+
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
96+
PIOS_Assert(0);
97+
}
98+
if (PIOS_COM_MSG_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id)) {
99+
PIOS_Assert(0);
100+
}
101+
#endif /* PIOS_INCLUDE_USB_HID && PIOS_INCLUDE_COM_MSG */
102+
103+
PIOS_USBHOOK_Activate();
104+
105+
#endif /* PIOS_INCLUDE_USB */
106+
}
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
******************************************************************************
3+
* @addtogroup TauLabsBootloader Tau Labs Bootloaders
4+
* @{
5+
* @addtogroup MiniM4BL MiniM4 bootloader
6+
* @{
7+
*
8+
* @file pios_config.h
9+
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
10+
* @author Tau Labs, http://taulabs.org, Copyright (C) 2012-2013
11+
* @brief Board specific bootloader configuration file for PiOS
12+
* @see The GNU Public License (GPL) Version 3
13+
*
14+
*****************************************************************************/
15+
/*
16+
* This program is free software; you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation; either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* This program is distributed in the hope that it will be useful, but
22+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24+
* for more details.
25+
*
26+
* You should have received a copy of the GNU General Public License along
27+
* with this program; if not, write to the Free Software Foundation, Inc.,
28+
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29+
*/
30+
31+
#ifndef PIOS_CONFIG_H
32+
#define PIOS_CONFIG_H
33+
34+
/* Enable/Disable PiOS Modules */
35+
#define PIOS_INCLUDE_DELAY
36+
#define PIOS_INCLUDE_IRQ
37+
#define PIOS_INCLUDE_LED
38+
#define PIOS_INCLUDE_SYS
39+
#define PIOS_INCLUDE_IAP
40+
#define PIOS_INCLUDE_USB
41+
#define PIOS_INCLUDE_USB_HID
42+
#define PIOS_INCLUDE_COM_MSG
43+
#define PIOS_INCLUDE_FLASH
44+
#define PIOS_INCLUDE_FLASH_INTERNAL
45+
46+
#endif /* PIOS_CONFIG_H */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
******************************************************************************
3+
* @addtogroup TauLabsBootloader Tau Labs Bootloaders
4+
* @{
5+
* @addtogroup MiniM4BL Quanton bootloader
6+
* @{
7+
*
8+
* @file pios_usb_board_data.c
9+
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
10+
* @author Tau Labs, http://taulabs.org, Copyright (C) 2012-2013
11+
* @brief Board specific USB definitions
12+
* @see The GNU Public License (GPL) Version 3
13+
*
14+
*****************************************************************************/
15+
/*
16+
* This program is free software; you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation; either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* This program is distributed in the hope that it will be useful, but
22+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24+
* for more details.
25+
*
26+
* You should have received a copy of the GNU General Public License along
27+
* with this program; if not, write to the Free Software Foundation, Inc.,
28+
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29+
*/
30+
#include "pios_usb_board_data.h" /* struct usb_*, USB_* */
31+
#include "pios_sys.h" /* PIOS_SYS_SerialNumberGet */
32+
#include "pios_usbhook.h" /* PIOS_USBHOOK_* */
33+
#include "pios_usb_util.h" /* PIOS_USB_UTIL_AsciiToUtf8 */
34+
35+
static const uint8_t usb_product_id[20] = {
36+
sizeof(usb_product_id),
37+
USB_DESC_TYPE_STRING,
38+
'm', 0,
39+
'i', 0,
40+
'n', 0,
41+
'i', 0,
42+
'm', 0,
43+
'4', 0,
44+
' ', 0,
45+
'f', 0,
46+
'c', 0,
47+
};
48+
49+
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1)*2] = {
50+
sizeof(usb_serial_number),
51+
USB_DESC_TYPE_STRING,
52+
};
53+
54+
static const struct usb_string_langid usb_lang_id = {
55+
.bLength = sizeof(usb_lang_id),
56+
.bDescriptorType = USB_DESC_TYPE_STRING,
57+
.bLangID = htousbs(USB_LANGID_ENGLISH_US),
58+
};
59+
60+
static const uint8_t usb_vendor_id[14] = {
61+
sizeof(usb_vendor_id),
62+
USB_DESC_TYPE_STRING,
63+
'Y', 0,
64+
'a', 0,
65+
'c', 0,
66+
'k', 0,
67+
'o', 0,
68+
'u', 0,
69+
};
70+
71+
int32_t PIOS_USB_BOARD_DATA_Init(void)
72+
{
73+
/* Load device serial number into serial number string */
74+
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
75+
PIOS_SYS_SerialNumberGet((char *)sn);
76+
77+
/* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
78+
uint8_t * utf8 = &(usb_serial_number[2]);
79+
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
80+
utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX)-1);
81+
82+
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
83+
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
84+
85+
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
86+
PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
87+
88+
return 0;
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
******************************************************************************
3+
* @addtogroup TauLabsBootloader Tau Labs Bootloaders
4+
* @{
5+
* @addtogroup MiniM4BL MiniM4 bootloader
6+
* @{
7+
*
8+
* @file pios_usb_board_data.h
9+
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
10+
* @author Tau Labs, http://taulabs.org, Copyright (C) 2012-2013
11+
* @brief Board specific USB definitions
12+
* @see The GNU Public License (GPL) Version 3
13+
*
14+
*****************************************************************************/
15+
/*
16+
* This program is free software; you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation; either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* This program is distributed in the hope that it will be useful, but
22+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24+
* for more details.
25+
*
26+
* You should have received a copy of the GNU General Public License along
27+
* with this program; if not, write to the Free Software Foundation, Inc.,
28+
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29+
*/
30+
31+
#ifndef PIOS_USB_BOARD_DATA_H
32+
#define PIOS_USB_BOARD_DATA_H
33+
34+
#define PIOS_USB_BOARD_HID_DATA_LENGTH 64
35+
36+
#define PIOS_USB_BOARD_EP_NUM 2
37+
38+
#include "pios_usb_defs.h" /* struct usb_* */
39+
40+
#define PIOS_USB_BOARD_VENDOR_ID 0x0fda //Quantec Networks GmbH
41+
#define PIOS_USB_BOARD_PRODUCT_ID 0x0100 //quanton flight control rev. 1
42+
#define PIOS_USB_BOARD_DEVICE_VER USB_OP_DEVICE_VER(0, USB_OP_BOARD_MODE_BL)
43+
#define PIOS_USB_BOARD_SN_SUFFIX "+BL"
44+
45+
/*
46+
* The bootloader uses a simplified report structure
47+
* BL: <REPORT_ID><DATA>...<DATA>
48+
* FW: <REPORT_ID><LENGTH><DATA>...<DATA>
49+
* This define changes the behaviour in pios_usb_hid.c
50+
*/
51+
#define PIOS_USB_BOARD_BL_HID_HAS_NO_LENGTH_BYTE
52+
53+
#endif /* PIOS_USB_BOARD_DATA_H */
54+
55+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
BOARD_TYPE := 0x86
2+
BOARD_REVISION := 0x01
3+
BOOTLOADER_VERSION := 0x81
4+
HW_TYPE := 0x00 # seems to be unused
5+
6+
MCU := cortex-m4
7+
CHIP := STM32F405RGT
8+
BOARD := STM32F4xx_MINIM4
9+
MODEL := HD
10+
MODEL_SUFFIX :=
11+
12+
OPENOCD_JTAG_CONFIG := jtagkey2p-ftdi.cfg
13+
OPENOCD_CONFIG := stm32f4xx-jtagkey.cfg
14+
15+
# Note: These must match the values in link_$(BOARD)_memory.ld
16+
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
17+
BL_BANK_SIZE := 0x00008000 # Should include BD_INFO region (32kb)
18+
19+
# Leave the remaining 16KB and 64KB sectors for other uses
20+
FW_BANK_BASE := 0x08020000 # Start of firmware flash (128kb)
21+
FW_BANK_SIZE := 0x00040000 # Should include FW_DESC_SIZE (256kb)
22+
#FW_BANK_BASE := 0x08000000 # Start of firmware flash (128kb)
23+
#FW_BANK_SIZE := 0x00100000 # Should include FW_DESC_SIZE (256kb)
24+
25+
FW_DESC_SIZE := 0x00000064
26+
27+
EE_BANK_BASE := 0x00000000
28+
EE_BANK_SIZE := 0x00000000
29+
30+
EF_BANK_BASE := 0x08000000 # Start of entire flash image (usually start of bootloader as well)
31+
EF_BANK_SIZE := 0x00060000 # Size of the entire flash image (from bootloader until end of firmware)
32+
33+
OSCILLATOR_FREQ := 16000000
34+
SYSCLK_FREQ := 168000000

0 commit comments

Comments
 (0)