191
|
1 To recompile the OSTC code you will need to install the following:
|
|
2 ------------------------------------------------------------------
|
|
3
|
|
4 - A Mercurial client, to download the source code and updates easily.
|
|
5 TortoiseHg is free, and works well.
|
|
6
|
|
7 - The Microchip MPLab IDE. This is free, and enable to recompile
|
|
8 all the assembly code, link, and produce a .hex file.
|
|
9
|
|
10 - If you want to modify the decompression algorithm, you will also
|
|
11 need the MPLab C18 compiler. There is a demo free for the first
|
|
12 30 days.
|
|
13 If you don't modify p2_deco.c, you don't need the C18 compiler,
|
|
14 see below.
|
|
15
|
|
16 - The Tiny bootloader for windows, see the HW site.
|
|
17
|
|
18
|
|
19 Creating a working project:
|
|
20 ---------------------------
|
|
21
|
|
22 - Launch the MPLab IDE.
|
|
23
|
|
24 - Create a new project (Project > Project Wizard...)
|
|
25 - Choose device PIC18F4685
|
|
26 - Select Microchip C18 Toolsuite (if you installed the C18 compiler)
|
|
27 or Microchip MPASM Toolsuite (if not)
|
|
28 --> Make sure the paths are corect.
|
|
29 - Choose a name and a directoty.
|
|
30
|
|
31 - Add the following files:
|
|
32 <my_source_path>/code_part1/OSTC_code_asm_part1/18f4685_ostc_mkII.lkr
|
|
33 <my_source_path>/code_part1/OSTC_code_asm_part1/MAIN.ASM
|
|
34 <my_source_path>/code_part1/OSTC_code_c_part2/p2_deco.o
|
|
35
|
|
36 (or use the .c instead of the .o if you have the C18 compiler)
|
|
37
|
|
38 - If you want to compile C code, configure it:
|
193
|
39 Menu: Project > Build Options... > Project > MPLab C18
|
191
|
40 General: Default storage = Overlay (-sco)
|
|
41 Optimization: Enable all
|
|
42
|
242
|
43 - Make sure the IDE is configured to find the "clib.lib" file
|
|
44 (needed even with precompiled p2_deco.o)
|
193
|
45 Menu : Project > Build Options ... > Project > Directories
|
|
46 Set «Search Directories» for : «Library Seach Path» to the path of the
|
|
47 “clib.lib” file (in c:\Program Files\Microship\MCC18\lib in my case)
|
|
48 Set «Build Directory Policy» to «Assemble/Compile in source-file directory, link in output directory»
|
|
49
|
242
|
50 - If you want to compile in DEBUG mode, select "Debug" in the build configuration
|
|
51 menu in the top-bar of the IDE.
|
|
52 It adds more safety tests into the code, so it is easier to spot bugs,
|
|
53 but generate firware NOT SUITABLE for diving !
|
|
54 ==> Always revert to Release and recompile everything once debugging is done.
|
|
55
|
|
56 - If you want a translated version (FRENCH, SPANISH, etc.), uncomment
|
|
57 the corresponding #define in definitions.asm
|
|
58
|
191
|
59 - Hit F10 to recompile everything.
|
|
60 --> You should get a .hex file where you saved your project.
|
|
61
|
|
62
|
|
63 Installing the new firmware
|
|
64 ---------------------------
|
|
65
|
242
|
66 - Get the .hex file you want to flash onto the OSTC Mk2.
|
191
|
67
|
|
68 - Connect the OSTC, wake it up.
|
|
69
|
|
70 - Launch the Tiny bootloader. It should work for some time, trying to open
|
|
71 the communication port.
|
|
72
|
|
73 - Once it is ready, Click Browse to select the .hex file
|
|
74 ==> DO NOT HIT Write Flash YET !
|
|
75
|
|
76 - On the OSTC, go to the reset menu, select Reboot OSTC
|
|
77 ==> DO NOT CONFIRM YET !
|
|
78
|
|
79 - Click "Write Flash" button. Now you have 10sec to confirm on OSTC too.
|
|
80
|
192
|
81 - The bootloader should say it found a 18F6485 device, and start uploading.
|
191
|
82 The OSTC should have the blue and red led blinking rapidly.
|
192
|
83 The upload time is ~ 20 secondes.
|
191
|
84
|
|
85 - Once done, the OSTC finishes its reboot.
|
|
86
|
|
87 - If you OSTC is stuck in some bad code, you can do the magic magnet reset
|
|
88 instead of choosing the reboot menu, during the 10sec timeslot after
|
|
89 starting bootloader write flash.
|
|
90
|
|
91
|
|
92
|