|
本帖最后由 MasterPhi 于 2014-10-30 06:03 编辑
今天D版的JLink V9终于到了,本人在国外,不过UPS还行,不到一星期就到了。
通电试了一下,发现坑得很,不知道是卖家的克隆技术不过关还是segger的保护比较狠,使用JLink Commander 经常出现 Error: Communication timed out: Requested 4 bytes, received 0 bytes,根本不能正常使用。
然后我把板子拆出来把所有焊盘加焊了一遍,还是没有解决。
于是我就想到是不是软件方面的问题,而且网上一搜之前v8也有相似的症状。干脆一不做二不休,看看能不能把flash里面的东西都搞出来。这些D版卖家也不厚道,把程序发出来就没那么多事了。
之前taoist放出了从JlinkARM.dll里面提取固件的工具http://www.amobbs.com/thread-5584993-2-1.html,
我就准备以这里为突破点,看一下能不能下载个小木马到固件部分,然后通过它把整个Flash读出来。
首先要确定的是能不能顺利把JlinkARM.dll里面的固件替换成我的程序,如果固件是加密存储的就比较麻烦了。于是我打开了JlinkARM.dll 我了个去。。。程序竟然是明文存储的!!!这样就好办了,直接替换就行。
对应程序起始地址为0x004525d0
于是我就写了个用uart把flash读出来的小程序,正好usart3的tx也就是pb10接着led,直观又不会和其他东西冲突。搞好后给我f407的板子编译了下,工作正常。
至于偏移地址, 我看中断向量表前两行都是0x0802开头的,那应该就是0x08020000了,看起来也正常,从128k处开始程序(悔啊。。。就是这里不小心。。也没多想干嘛一个bootloader要留128k)
编译好了,将程序替换到JlinkARM.dll,沉住气,开刷,结果提示错误,大体意思是没有找到日期字符串。
对比原程序后,感觉应该少的是这一块,便调整了linker,把这一区块手动加到了程序里。
再一次更新固件,这一次没有出错,成功刷入了!
但是led没有闪烁,就是说usart3没有数据出来。。。 接usb当然是不会有反应了。。。
难道说我的jlink就这么挂了? 不甘心,我便检查了每个步骤,这时发现怎么原程序里面有几个中断向量是0x0801开头的! 难道偏移是0x08010000?
死马当活马医,用stlink把芯片擦了,然后把源程序下载到0x08010000,然后在0x08000000处理一下让程序一运行就跳到0x08010000
上电,jlink竟然重新识别出来了! 这样就验证了偏移的确是0x08010000。
可是因为擦了flash,什么gdb,jflash等的license都没了。。。成了纯裸机。。。
奇怪的是运行gdb,jflash竟然没问我的license。。。。。
悔啊。。。就一步不小心。。。否则就能造福大家了
一起上传读flash的小程序,给不怕死的坛友
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f2xx.h"
- /** @addtogroup Template_Project
- * @{
- */
- USART_InitTypeDef USART_InitStructure;
- GPIO_InitTypeDef GPIO_InitStructure;
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Private function prototypes -----------------------------------------------*/
- /* Private functions ---------------------------------------------------------*/
- void Send(u8 data);
- /**
- * @brief Main program.
- * @param None
- * @retval None
- */
- int main(void)
- {
- u8* i;
- /*!< At this stage the microcontroller clock setting is already configured,
- this is done through SystemInit() function which is called from startup
- file (startup_stm32f2xx.s) before to branch to application main.
- To reconfigure the default setting of SystemInit() function, refer to
- system_stm32f2xx.c file
- */
- /* Enable GPIO clock */
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
- /* Enable UART clock */
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
-
- /* Connect PXx to USARTx_Tx*/
- GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3);
-
- /* Configure USART Tx as alternate function */
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
-
-
- USART_InitStructure.USART_BaudRate = 19200;
- USART_InitStructure.USART_WordLength = USART_WordLength_8b;
- USART_InitStructure.USART_StopBits = USART_StopBits_1;
- USART_InitStructure.USART_Parity = USART_Parity_No;
- USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
- USART_InitStructure.USART_Mode = USART_Mode_Tx;
-
- /* USART configuration */
- USART_Init(USART3, &USART_InitStructure);
-
- /* Enable USART */
- USART_Cmd(USART3, ENABLE);
- /* Add your application code here
- */
-
- /* Infinite loop */
- while (1)
- {
- Send(88u);
- Send(88u);
- Send(88u);
- Send(88u);
- for(i=(u8*)0x08000000;i<(u8*)0x08040000;i++)
- {
- Send(*i);
- }
- }
- }
- void Send(u8 data)
- {
- USART_SendData(USART3, (uint8_t) data);
- /* Loop until the end of transmission */
- while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET)
- {}
- }
- #ifdef USE_FULL_ASSERT
- /**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval None
- */
- void assert_failed(uint8_t* file, uint32_t line)
- {
- /* User can add his own implementation to report the file name and line number,
- ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
-
- /* Infinite loop */
- while (1)
- {
- }
- }
- #endif
- /**
- * @}
- */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|