Skip to content

Commit 0785dae

Browse files
committed
update build for ra8m1: usbfs work, but usbhs not working just yet. Probably missing configuration or clock setup
1 parent c79890c commit 0785dae

File tree

12 files changed

+393
-48
lines changed

12 files changed

+393
-48
lines changed

hw/bsp/ra/boards/ra6m5_ek/board.cmake

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@ set(CMAKE_SYSTEM_PROCESSOR cortex-m33 CACHE INTERNAL "System Processor")
22
set(MCU_VARIANT ra6m5)
33

44
set(JLINK_DEVICE R7FA6M5BH)
5-
#set(JLINK_OPTION "-USB 000831915224")
5+
set(JLINK_OPTION "-USB 000831915224")
66

7-
# Device port default to PORT1 Highspeed
8-
if (NOT DEFINED PORT)
9-
set(PORT 1)
7+
# device default to PORT 1 High Speed
8+
if (NOT DEFINED RHPORT_DEVICE)
9+
set(RHPORT_DEVICE 1)
10+
endif()
11+
if (NOT DEFINED RHPORT_HOST)
12+
set(RHPORT_HOST 0)
1013
endif()
11-
12-
# Host port will be the other port
13-
set(HOST_PORT $<NOT:${PORT}>)
1414

1515
function(update_board TARGET)
16-
target_compile_definitions(${TARGET} PUBLIC
17-
BOARD_TUD_RHPORT=${PORT}
18-
BOARD_TUH_RHPORT=${HOST_PORT}
19-
# port 0 is fullspeed, port 1 is highspeed
20-
BOARD_TUD_MAX_SPEED=$<IF:${PORT},OPT_MODE_HIGH_SPEED,OPT_MODE_FULL_SPEED>
21-
BOARD_TUH_MAX_SPEED=$<IF:${HOST_PORT},OPT_MODE_HIGH_SPEED,OPT_MODE_FULL_SPEED>
22-
)
2316
endfunction()

hw/bsp/ra/boards/ra6m5_ek/board.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ MCU_VARIANT = ra6m5
55
JLINK_DEVICE = R7FA6M5BH
66

77
# Port 1 is highspeed
8-
PORT ?= 1
8+
RHPORT_DEVICE ?= 1
9+
RHPORT_HOST ?= 0
910

1011
flash: flash-jlink

hw/bsp/ra/boards/ra6m5_ek/ozone/ra6m5.jdebug

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ void OnProjectLoad (void) {
2020
Project.SetTraceSource ("Trace Pins");
2121
Project.SetTracePortWidth (4);
2222

23-
//File.Open ("../../../../../../examples/device/cdc_msc/cmake-build-ra6m5/cdc_msc.elf");
24-
//File.Open ("../../../../../../examples/dual/cmake-build-ra6m5/host_hid_to_device_cdc/host_hid_to_device_cdc.elf");
25-
File.Open ("../../../../../../examples/cmake-build-ra6m5/host/cdc_msc_hid/cdc_msc_hid.elf");
23+
File.Open ("../../../../../../examples/cmake-build-ra6m5_ek/device/cdc_msc/cdc_msc.elf");
2624
}
2725
/*********************************************************************
2826
*

hw/bsp/ra/boards/ra8m1_ek/board.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@ set(MCU_VARIANT ra8m1)
44
set(JLINK_DEVICE R7FA8M1AH)
55
#set(JLINK_OPTION "-USB 001083115236")
66

7+
# device default to PORT 1 High Speed
8+
if (NOT DEFINED RHPORT_DEVICE)
9+
set(RHPORT_DEVICE 1)
10+
endif()
11+
if (NOT DEFINED RHPORT_HOST)
12+
set(RHPORT_HOST 0)
13+
endif()
14+
715
function(update_board TARGET)
816
endfunction()

hw/bsp/ra/boards/ra8m1_ek/board.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CPU_CORE = cortex-m85
2+
MCU_VARIANT = ra8m1
3+
4+
# For flash-jlink target
5+
JLINK_DEVICE = R7FA8M1AH
6+
7+
# Port 1 is highspeed
8+
RHPORT_DEVICE ?= 1
9+
RHPORT_HOST ?= 0
10+
11+
flash: flash-jlink
Binary file not shown.
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
2+
/*********************************************************************
3+
*
4+
* OnProjectLoad
5+
*
6+
* Function description
7+
* Project load routine. Required.
8+
*
9+
**********************************************************************
10+
*/
11+
void OnProjectLoad (void) {
12+
Project.SetTraceSource ("Trace Pins");
13+
Project.SetDevice ("R7FA8M1AH");
14+
Project.SetHostIF ("USB", "");
15+
Project.SetTargetIF ("SWD");
16+
Project.SetTIFSpeed ("50 MHz");
17+
18+
Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M85F.svd");
19+
Project.AddSvdFile ("../../../../../../../cmsis-svd-data/data/Renesas/R7FA6M5BH.svd");
20+
21+
File.Open ("../../../../../../examples/cmake-build-ra8m1_ek/device/cdc_msc/cdc_msc.elf");
22+
}
23+
/*********************************************************************
24+
*
25+
* BeforeTargetConnect
26+
*
27+
* Function description
28+
* Event handler routine. Optional.
29+
*
30+
**********************************************************************
31+
*/
32+
void BeforeTargetConnect (void) {
33+
// Trace pin init is done by J-Link script file as J-Link script files are IDE independent
34+
//Project.SetJLinkScript("../../../debug.jlinkscript");
35+
Project.SetJLinkScript ("$(ProjectDir)/Renesas_RA8_TracePins.pex");
36+
}
37+
38+
/*********************************************************************
39+
*
40+
* AfterTargetConnect
41+
*
42+
* Function description
43+
* Event handler routine. Optional.
44+
*
45+
**********************************************************************
46+
*/
47+
//void AfterTargetConnect (void) {
48+
//}
49+
50+
/*********************************************************************
51+
*
52+
* TargetDownload
53+
*
54+
* Function description
55+
* Replaces the default program download routine. Optional.
56+
*
57+
**********************************************************************
58+
*/
59+
//void TargetDownload (void) {
60+
//}
61+
62+
/*********************************************************************
63+
*
64+
* BeforeTargetDownload
65+
*
66+
* Function description
67+
* Event handler routine. Optional.
68+
*
69+
**********************************************************************
70+
*/
71+
//void BeforeTargetDownload (void) {
72+
//}
73+
74+
/*********************************************************************
75+
*
76+
* AfterTargetDownload
77+
*
78+
* Function description
79+
* Event handler routine. Optional.
80+
* The default implementation initializes SP and PC to reset values.
81+
*
82+
**********************************************************************
83+
*/
84+
void AfterTargetDownload (void) {
85+
_SetupTarget();
86+
}
87+
88+
/*********************************************************************
89+
*
90+
* BeforeTargetDisconnect
91+
*
92+
* Function description
93+
* Event handler routine. Optional.
94+
*
95+
**********************************************************************
96+
*/
97+
//void BeforeTargetDisconnect (void) {
98+
//}
99+
100+
/*********************************************************************
101+
*
102+
* AfterTargetDisconnect
103+
*
104+
* Function description
105+
* Event handler routine. Optional.
106+
*
107+
**********************************************************************
108+
*/
109+
//void AfterTargetDisconnect (void) {
110+
//}
111+
112+
/*********************************************************************
113+
*
114+
* AfterTargetHalt
115+
*
116+
* Function description
117+
* Event handler routine. Optional.
118+
*
119+
**********************************************************************
120+
*/
121+
//void AfterTargetHalt (void) {
122+
//}
123+
124+
/*********************************************************************
125+
*
126+
* BeforeTargetResume
127+
*
128+
* Function description
129+
* Event handler routine. Optional.
130+
*
131+
**********************************************************************
132+
*/
133+
//void BeforeTargetResume (void) {
134+
//}
135+
136+
/*********************************************************************
137+
*
138+
* OnSnapshotLoad
139+
*
140+
* Function description
141+
* Called upon loading a snapshot. Optional.
142+
*
143+
* Additional information
144+
* This function is used to restore the target state in cases
145+
* where values cannot simply be written to the target.
146+
* Typical use: GPIO clock needs to be enabled, before
147+
* GPIO is configured.
148+
*
149+
**********************************************************************
150+
*/
151+
//void OnSnapshotLoad (void) {
152+
//}
153+
154+
/*********************************************************************
155+
*
156+
* OnSnapshotSave
157+
*
158+
* Function description
159+
* Called upon saving a snapshot. Optional.
160+
*
161+
* Additional information
162+
* This function is usually used to save values of the target
163+
* state which can either not be trivially read,
164+
* or need to be restored in a specific way or order.
165+
* Typically use: Memory Mapped Registers,
166+
* such as PLL and GPIO configuration.
167+
*
168+
**********************************************************************
169+
*/
170+
//void OnSnapshotSave (void) {
171+
//}
172+
173+
/*********************************************************************
174+
*
175+
* OnError
176+
*
177+
* Function description
178+
* Called when an error occurred. Optional.
179+
*
180+
**********************************************************************
181+
*/
182+
//void OnError (void) {
183+
//}
184+
185+
/*********************************************************************
186+
*
187+
* AfterProjectLoad
188+
*
189+
* Function description
190+
* After Project load routine. Optional.
191+
*
192+
**********************************************************************
193+
*/
194+
//void AfterProjectLoad (void) {
195+
//}
196+
197+
/*********************************************************************
198+
*
199+
* _SetupTarget
200+
*
201+
* Function description
202+
* Setup the target.
203+
* Called by AfterTargetReset() and AfterTargetDownload().
204+
*
205+
* Auto-generated function. May be overridden by Ozone.
206+
*
207+
**********************************************************************
208+
*/
209+
void _SetupTarget(void) {
210+
unsigned int SP;
211+
unsigned int PC;
212+
unsigned int VectorTableAddr;
213+
214+
VectorTableAddr = Elf.GetBaseAddr();
215+
//
216+
// Set up initial stack pointer
217+
//
218+
SP = Target.ReadU32(VectorTableAddr);
219+
if (SP != 0xFFFFFFFF) {
220+
Target.SetReg("SP", SP);
221+
}
222+
//
223+
// Set up entry point PC
224+
//
225+
PC = Elf.GetEntryPointPC();
226+
if (PC != 0xFFFFFFFF) {
227+
Target.SetReg("PC", PC);
228+
} else {
229+
Util.Error("Project script error: failed to set up entry point PC", 1);
230+
}
231+
}

hw/bsp/ra/boards/ra8m1_ek/ra_gen/bsp_clock_cfg.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#define BSP_CFG_PLL_FREQUENCY_HZ (960000000) /* PLL 960000000Hz */
1212
#define BSP_CFG_PLODIVP (BSP_CLOCKS_PLL_DIV_2) /* PLL1P Div /2 */
1313
#define BSP_CFG_PLL1P_FREQUENCY_HZ (480000000) /* PLL1P 480000000Hz */
14-
#define BSP_CFG_PLODIVQ (BSP_CLOCKS_PLL_DIV_2) /* PLL1Q Div /2 */
15-
#define BSP_CFG_PLL1Q_FREQUENCY_HZ (480000000) /* PLL1Q 480000000Hz */
14+
#define BSP_CFG_PLODIVQ (BSP_CLOCKS_PLL_DIV_4) /* PLL1Q Div /4 */
15+
#define BSP_CFG_PLL1Q_FREQUENCY_HZ (240000000) /* PLL1Q 240000000Hz */
1616
#define BSP_CFG_PLODIVR (BSP_CLOCKS_PLL_DIV_2) /* PLL1R Div /2 */
1717
#define BSP_CFG_PLL1R_FREQUENCY_HZ (480000000) /* PLL1R 480000000Hz */
1818
#define BSP_CFG_PLL2_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* PLL2 Disabled */
@@ -31,8 +31,8 @@
3131
#define BSP_CFG_SPICLK_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* SPICLK Disabled */
3232
#define BSP_CFG_CANFDCLK_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* CANFDCLK Disabled */
3333
#define BSP_CFG_I3CCLK_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* I3CCLK Disabled */
34-
#define BSP_CFG_UCK_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* UCK Disabled */
35-
#define BSP_CFG_U60CK_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* U60CK Disabled */
34+
#define BSP_CFG_UCK_SOURCE (BSP_CLOCKS_SOURCE_CLOCK_PLL1Q) /* UCK Src: PLL1Q */
35+
#define BSP_CFG_U60CK_SOURCE (BSP_CLOCKS_SOURCE_CLOCK_PLL1P) /* U60CK Src: PLL1P */
3636
#define BSP_CFG_OCTA_SOURCE (BSP_CLOCKS_CLOCK_DISABLED) /* OCTASPICLK Disabled */
3737
#define BSP_CFG_CPUCLK_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_1) /* CPUCLK Div /1 */
3838
#define BSP_CFG_ICLK_DIV (BSP_CLOCKS_SYS_CLOCK_DIV_2) /* ICLK Div /2 */
@@ -51,6 +51,6 @@
5151
#define BSP_CFG_CANFDCLK_DIV (BSP_CLOCKS_CANFD_CLOCK_DIV_8) /* CANFDCLK Div /8 */
5252
#define BSP_CFG_I3CCLK_DIV (BSP_CLOCKS_I3C_CLOCK_DIV_3) /* I3CCLK Div /3 */
5353
#define BSP_CFG_UCK_DIV (BSP_CLOCKS_USB_CLOCK_DIV_5) /* UCK Div /5 */
54-
#define BSP_CFG_U60CK_DIV (BSP_CLOCKS_USB_CLOCK_DIV_5) /* U60CK Div /5 */
54+
#define BSP_CFG_U60CK_DIV (BSP_CLOCKS_USB_CLOCK_DIV_8) /* U60CK Div /8 */
5555
#define BSP_CFG_OCTA_DIV (BSP_CLOCKS_OCTA_CLOCK_DIV_4) /* OCTASPICLK Div /4 */
5656
#endif /* BSP_CLOCK_CFG_H_ */

0 commit comments

Comments
 (0)