среда, 20 мая 2015 г.

How to build .NET Micro Framework 4.3 CLR for STM32F4Discovery

The problem: last available .NET Micro Framework pre-built CLR version for STM32F4Discovery is 4.2. It has some issues with debugging and lacks support for a few important components (like 1-Wire interface).
You can use pre-built .NET Micro Framework 4.3 beta from http://mountaineer.org but in this case you have to modify your STM32F4Discovery to replace the X2 8 MHz crystal with a 12 MHz crystal and remove R68 jumper. Follow the link for details.
Here is a short description on how to build .NETMF 4.3 from source without any STM32F4Discovery's hardware modifications.
  1. Download and install Visual Studio 2013 Update 4
  2. Install it to C:\GCC_ARM_4_6 (DO NOT use spaces)
  3. Download community ports collection https://github.com/funkathustra/netmf-community-ports
  4. Extract it to C:\MicroFrameworkPK_4_3
  5. Navigate to C:\MicroFrameworkPK_4_3\Solutions\FEZCerberus\platform_selector.h and modify it to fit STM32F4Discovery's peripherals (note that FEZCerberus uses MCU with less flash memory and less peripherals, below are only changed lines):
    • #define TOTAL_GPIO_PORT 5
    • #define TOTAL_USART_PORT 6
    • #define TOTAL_USB_CONTROLLER 2
    • #define USB_MAX_QUEUES 6
    • #define STM32F4_32B_TIMER 2
    • #define STM32F4_16B_TIMER 3
    • #define STM32F4_ADC 1
    • #define STM32F4_AD_CHANNELS {1,2,3,8,9,14,15} // PA1,PA2,PA3,PB0,PB1,PC4,PC5
    • #define STM32F4_PWM_TIMER {4,4,4,4,1,1,1,1}
    • #define STM32F4_PWM_CHNL  {0,1,2,3,0,1,2,3}
    • #define STM32F4_PWM_PINS  {60,61,62,63,73,75,77,78} // D12-D15,E9,E11,E13,E14
    • #define STM32F4_SPI_SCLK_PINS {5,29,42} // PA5, PB13, PC10
    • #define STM32F4_SPI_MISO_PINS {6,30,43} // PA6, PB14, PC11
    • #define STM32F4_SPI_MOSI_PINS {7,31,44} // PA7, PB15, PC12
    • #define STM32F4_I2C_SDA_PIN 25 // PB9
    • #define STM32F4_UART_RXD_PINS {10,3,57,43,50,39} // A10, A3, D9, C11, D2, C7
    • #define STM32F4_UART_TXD_PINS {9,2,56,42,44,38} // A9, A2, D8, C10, C12, C6
    • #define STM32F4_UART_CTS_PINS {11,51,59} // A11, D3, D11
    • #define STM32F4_UART_RTS_PINS {12,1,60} // A12, A1, D12
  6. Navigate to C:\MicroFrameworkPK_4_3\Solutions\FEZCerberus\TinyCLR\scatterfile_tinyclr_gcc.xml, find Deploy_BaseAddress and change it's value to 0x080A0000 otherwise tinyCLR will not fit into dedicated flash region
  7. Using system properties, add the folder C:\Windows\Microsoft.NET\Framework64\v4.0.30319 or C:\Windows\Microsoft.NET\Framework\v4.0.30319 (depends on your system's architecture)
  8. Run command-line
  9. Execute command set VS110COMNTOOLS=%VS120COMNTOOLS%
  10. Execute command cd /d C:\MicroFrameworkPK_4_3
  11. Execute command setenv_gcc.cmd 4.6.2 C:\GCC_ARM_4_6
  12. Execute command cd Solutions\FEZCerberus
  13. Execute command msbuild /t:build /p:flavor=release;memory=flash
  14. Execution will take a long time
  15. Now find built TinyCLR and TinyBooter in C:\MicroFrameworkPK_4_3\BuildOutput\THUMB2\GCC4.6\le\FLASH\release\FEZCerberus\bin directory
The resulting CLR version is 4.3.0.
Known issues:
  • USARTS from 4 to 6 are not operable. No workaround now.
  • Float to string conversion replaces zeroes with spaces after decimal point (thus, 14.02 becomes "14. 2"). Workaround: implement custom conversion class/function.

4 комментария: