完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我手上的板子是 hpm6750evkmini.yaml ,带了 16MB的外置 SDDRAM。用起来有个问题, 1)如果使用 -DCMAKE_BUILD_TYPE=debug_flash_sdram_xip,则每次烧写到NOR FLASH 太慢,等待消耗太长时间。 2)如果使用 -DCMAKE_BUILD_TYPE=debug,则镜像写到 ILM中,但又受限与 ILM的大小。 因此手撸了一个将镜像烧写到 SDRAM 的配置,支持 make flash 直接烧写到 FLASH 或者 SDRAM 中。以 hello_world为例,需要改动的文件 1) soc/HPM6750/toolchains/gcc/ram.ld 此文件需要调整各个 section 的布局(即加载地址 LMA 和 执行地址VMA)。 文件在文末提供,复制并覆盖到 ram.ld即可。 2) samples/hello_world/CMakeLists.txt 此文件需要加上一些代码以支持 make flash,完整文件在文末提供,复制并覆盖到 hello_world/CMakeLists.txt 文件即可。 一、烧写到 SDRAM 中 $ cd hello_world/build $ cmake -DCMAKE_BUILD_TYPE=debug -DBOARD=hpm6750evkmini .. $ make flash 二、烧写到 FLASH 中 $ cd hello_world/build $ cmake -DCMAKE_BUILD_TYPE=debug_flash_sdram_xip -DBOARD=hpm6750evkmini .. $ make flash 三、在 SDRAM 中调试 1)先编译 $ cd hello_world/build $ cmake -DCMAKE_BUILD_TYPE=debug_flash_sdram_xip -DBOARD=hpm6750evkmini .. $ make 2)启动 openocd $ openocd -f ${HPM_SDK_BASE}/boards/openocd/probes/ft2232.cfg -f ${HPM_SDK_BASE}/boards/openocd/soc/hpm6750-single-core.cfg -f ${HPM_SDK_BASE}/boards/openocd/boards/hpm6750evkmini.cfg 3)新开一个 终端窗口进行调试 $ cd hello_world/build $ riscv32-unknown-elf-gdb output/demo.elf > target remote localhost:3333 > monitor reset init > load > b main > c --------------------------- 以下为 hello_world/CMakeLists.txt ---------------------------------- # Copyright (c) 2021 HPMicro # SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.13) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(hpm-sdk REQUIRED HINTS $ENV{HPM_SDK_BASE}) project(hello_world) SET(OPENOCD_DRV $ENV{HPM_SDK_BASE}/boards/openocd/probes/ft2232.cfg) SET(OPENOCD_SOC $ENV{HPM_SDK_BASE}/boards/openocd/soc/hpm6750-single-core.cfg) SET(OPENOCD_BRD $ENV{HPM_SDK_BASE}/boards/openocd/boards/hpm6750evkmini.cfg) SET(ELF_FILE ${PROJECT_BINARY_DIR}/output/${APP_NAME}.elf) SET(BIN_FILE ${PROJECT_BINARY_DIR}/output/${APP_NAME}.bin) SET(HEX_FILE ${PROJECT_BINARY_DIR}/output/${APP_NAME}.hex) message(STATUS "elf: ${ELF_FILE}") message(STATUS "bin: ${BIN_FILE}") message(STATUS "hex: ${HEX_FILE}") string(TOLOWER ${CMAKE_BUILD_TYPE} build_type) string(FIND ${build_type} "flash" found) if (${found} GREATER_EQUAL 0) message(STATUS "run on flash") add_custom_target(flash COMMAND "${CROSS_COMPILE}objcopy" -O ihex -S ${ELF_FILE} ${HEX_FILE} COMMAND openocd -f ${OPENOCD_DRV} -f ${OPENOCD_SOC} -f ${OPENOCD_BRD} -c 'init' -c 'reset init' -c 'program ${HEX_FILE} verify' -c 'reset' -c 'shutdown' DEPENDS ${APP_ELF_NAME} ) else() message(STATUS "run on ram") #sdk_compile_definitions(-DFLASH_XIP=1 -DINIT_EXT_RAM_FOR_DATA=1) sdk_compile_definitions(-DFLASH_XIP=1) add_custom_target(flash COMMAND openocd -f ${OPENOCD_DRV} -f ${OPENOCD_SOC} -f ${OPENOCD_BRD} -c 'init' -c 'reset init' -c 'load_image ${BIN_FILE} 0x40c00000' -c 'resume 0x40c00000' -c 'shutdown' DEPENDS ${APP_ELF_NAME} ) endif() sdk_compile_definitions(-DBOARD_SHOW_CLOCK=1 -DBOARD_SHOW_BANNER=1) sdk_app_src(src/hello_world.c) generate_ses_project() --------------------------- 以下为 soc/HPM6750/toolchains/gcc/ram.ld ---------------------------------- /* * Copyright (c) 2021-2022 HPMicro * SPDX-License-Identifier: BSD-3-Clause */ ENTRY(_start) STACK_SIZE = DEFINED(_stack_size) ? _stack_size : 0x4000; HEAP_SIZE = DEFINED(_heap_size) ? _heap_size : 0x4000; MEMORY { ILM (wx) : ORIGIN = 0x00000000, LENGTH = 256K DLM (w) : ORIGIN = 0x00080000, LENGTH = 256K AXI_SRAM (wx) : ORIGIN = 0x01080000, LENGTH = 768K /* AXI SRAM */ SHARE_RAM (w) : ORIGIN = 0x0117C000, LENGTH = 16K AHB_SRAM (w) : ORIGIN = 0xF0300000, LENGTH = 32k APB_SRAM (w) : ORIGIN = 0xF40F0000, LENGTH = 8k SDRAM (wx) : ORIGIN = 0x40000000, LENGTH = (_extram_size - 8M) NONCACHEABLE_RAM (wx) : ORIGIN = 0x40000000 + (_extram_size - 8M), LENGTH = 4M XPI0 (rx) : ORIGIN = 0x40000000 + (_extram_size - 4M), LENGTH = 4M } SECTIONS { .start : { . = ALIGN(8); KEEP(*(.start)) } > XPI0 __vector_load_addr__ = ORIGIN(XPI0) + SIZEOF(.start); .vectors ORIGIN(ILM) : AT(__vector_load_addr__) { . = ALIGN(8); __vector_ram_start__ = .; KEEP(*(.vector_table)) KEEP(*(.isr_vector)) . = ALIGN(8); __vector_ram_end__ = .; } > ILM __nor_cfg_option_load_addr__ = __vector_load_addr__ + SIZEOF(.vectors); .nor_cfg_option __nor_cfg_option_load_addr__ : { KEEP(*(.nor_cfg_option)) } > XPI0 __boot_header_load_addr__ = __nor_cfg_option_load_addr__ + SIZEOF(.nor_cfg_option); .boot_header __boot_header_load_addr__ : { __boot_header_start__ = .; KEEP(*(.boot_header)) KEEP(*(.fw_info_table)) KEEP(*(.dc_info)) __boot_header_end__ = .; } > XPI0 __text_load_addr__ = __boot_header_load_addr__ + SIZEOF(.boot_header); .text __text_load_addr__ : { . = ALIGN(8); *(.text) *(.text*) *(.rodata) *(.rodata*) *(.srodata) *(.srodata*) *(.hash) *(.dyn*) *(.gnu*) *(.pl*) KEEP(*(.eh_frame)) *(.eh_frame*) KEEP (*(.init)) KEEP (*(.fini)) . = ALIGN(8); } > XPI0 __rel_load_addr__ = __text_load_addr__ + SIZEOF(.text); .rel __rel_load_addr__ : { KEEP(*(.rel*)) } > XPI0 __usbh_class_info__load_addr__ = __rel_load_addr__ + SIZEOF(.rel); .usbh_class_info __usbh_class_info__load_addr__ : { . = ALIGN(4); __usbh_class_info_start__ = .; KEEP(*(.usbh_class_info)) __usbh_class_info_end__ = .; . = ALIGN(8); } > XPI0 __etext_load_addr__ = __usbh_class_info__load_addr__ + SIZEOF(.usbh_class_info); PROVIDE (__etext = __etext_load_addr__); PROVIDE (_etext = __etext_load_addr__); PROVIDE (etext = __etext_load_addr__); .data : AT(etext) { . = ALIGN(8); __data_start__ = .; __global_pointer$ = . + 0x800; *(.data) *(.data*) *(.sdata) *(.sdata*) *(.tdata) *(.tdata*) KEEP(*(.jcr)) KEEP(*(.dynamic)) KEEP(*(.got*)) KEEP(*(.got)) KEEP(*(.gcc_except_table)) KEEP(*(.gcc_except_table.*)) . = ALIGN(8); PROVIDE(__preinit_array_start = .); KEEP(*(.preinit_array)) PROVIDE(__preinit_array_end = .); . = ALIGN(8); PROVIDE(__init_array_start = .); KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*))) KEEP(*(.init_array)) PROVIDE(__init_array_end = .); . = ALIGN(8); PROVIDE(__finit_array_start = .); KEEP(*(SORT_BY_INIT_PRIORITY(.finit_array.*))) KEEP(*(.finit_array)) PROVIDE(__finit_array_end = .); . = ALIGN(8); KEEP(*crtbegin*.o(.ctors)) KEEP(*(EXCLUDE_FILE (*crtend*.o) .ctors)) KEEP(*(SORT(.ctors.*))) KEEP(*(.ctors)) . = ALIGN(8); KEEP(*crtbegin*.o(.dtors)) KEEP(*(EXCLUDE_FILE (*crtend*.o) .dtors)) KEEP(*(SORT(.dtors.*))) KEEP(*(.dtors)) . = ALIGN(8); __data_end__ = .; PROVIDE (__edata = .); PROVIDE (_edata = .); PROVIDE (edata = .); } > SDRAM .fast ORIGIN(ILM) + SIZEOF(.vectors) : AT(etext + SIZEOF(.data)) { . = ALIGN(8); PROVIDE(__ramfunc_start__ = .); *(.fast) . = ALIGN(8); PROVIDE(__ramfunc_end__ = .); } > ILM .noncacheable : AT(etext + SIZEOF(.data) + SIZEOF(.fast)) { . = ALIGN(8); __noncacheable_init_start__ = .; KEEP(*(.noncacheable.init)) __noncacheable_init_end__ = .; KEEP(*(.noncacheable)) __noncacheable_bss_start__ = .; KEEP(*(.noncacheable.bss)) __noncacheable_bss_end__ = .; . = ALIGN(8); } > NONCACHEABLE_RAM __fw_size__ = __ramfunc_end__ - __ramfunc_start__ + __data_end__ - __data_start__; .bss (NOLOAD) : { . = ALIGN(8); __bss_start__ = .; *(.bss) *(.bss*) *(.tbss*) *(.sbss*) *(.scommon) *(.scommon*) *(.tcommon*) *(.dynsbss*) *(COMMON) . = ALIGN(8); _end = .; __bss_end__ = .; } > SDRAM .framebuffer (NOLOAD) : { . = ALIGN(8); KEEP(*(.framebuffer)) . = ALIGN(8); } > SDRAM .sh_mem (NOLOAD) : { KEEP(*(.sh_mem)) } > SHARE_RAM .ahb_sram (NOLOAD) : { KEEP(*(.ahb_sram)) } > AHB_SRAM .apb_sram (NOLOAD) : { KEEP(*(.backup_sram)) } > APB_SRAM .heap (NOLOAD) : { . = ALIGN(8); __heap_start__ = .; . += HEAP_SIZE; __heap_end__ = .; } > SDRAM .stack (NOLOAD) : { . = ALIGN(8); __stack_base__ = .; . += STACK_SIZE; . = ALIGN(8); PROVIDE (_stack = .); PROVIDE (_stack_safe = .); } > DLM .fast_ram (NOLOAD) : { . = ALIGN(8); KEEP(*(.fast_ram)) } > DLM __noncacheable_start__ = ORIGIN(NONCACHEABLE_RAM); __noncacheable_end__ = ORIGIN(NONCACHEABLE_RAM) + LENGTH(NONCACHEABLE_RAM); __share_mem_start__ = ORIGIN(SHARE_RAM); __share_mem_end__ = ORIGIN(SHARE_RAM) + LENGTH(SHARE_RAM); } |
|
相关推荐
1 条评论
|
|
只有小组成员才能发言,加入小组>>
397个成员聚集在这个小组
加入小组自己做的hpm5321和6750板子怎么都没有1.1的输出呢?
978 浏览 1 评论
关于hpm6364的femc同时使用外接sdram和sram的问题
829 浏览 1 评论
788 浏览 0 评论
703 浏览 1 评论
804 浏览 0 评论
【盖楼抢好礼】欢迎先楫半导体HPMicro入驻电子发烧友社区!
24554浏览 532评论
2569浏览 22评论
USBX范例中启用 double FPU , 运行异常,卡死在tx_risc_v_trap_handler函数
2926浏览 5评论
1741浏览 5评论
请问Segger Embedded Studio这个窗口不小心拉出来悬浮后怎么塞回去?
2895浏览 5评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 19:24 , Processed in 0.512719 second(s), Total 47, Slave 40 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号