Jump to content
IGNORED

CDFJ support?


Andrew Davie

Recommended Posts

5 minutes ago, Thomas Jentzsch said:

I think some find and replace would work here:

  1. Replace 0x00... with e.g. xxxx....
  2. Replace 0x.... with 0x2000
  3. Replace xxxx with 0x00

But I don't know command line tools which could be integrated into the makefile.

 

It sounds dangerous to me.

 

The awk script processes the DASM symbols file. Some are offsets into flash and some are just numeric values. The script could be altered so that 0x2000000 is ORed with the value in the symbols file but that would alter the non-address values too.

 

If you change line 63 of the Makefile to

 

      awk '$$0 ~ /^_/ {printf "#define %-25s 0x2000%s\n", $$1, $$2}' $(PROJECT).sym >> main/$(DASM_TO_C)

 

Then that *might* work. But as I say, that changes all values not just the ones you want.

 

I've not looked at Andrew's code yet but I would start searching for references to those symbols in the C code and have a think about whether they are memory accesses or not. If they are then add the ROM value.

 

 

Link to comment
Share on other sites

Attached are the common files I changed (just a quick hack). IMO these should be provided and maintained from the UnoCart/PlusCart groups. And of course the CDF(J) etc. schemes have to implemented first.

custom.boot.lds custom.S

defines_cdfj.h

Edited by Thomas Jentzsch
  • Thanks 1
Link to comment
Share on other sites

24 minutes ago, Thomas Jentzsch said:

Attached are the common files I changed (just a quick hack). IMO these should be provided and maintained from the UnoCart/PlusCart groups. And of course the CDF(J) etc. schemes have to implemented first.

defines_cdfj.h 5.84 kB · 3 downloads custom.boot.lds 1.73 kB · 1 download custom.S 1.56 kB · 1 download

I am not sure, but I think in defines_cdfj.h lines 70, 83, 95 and 122 need a "ROM_BASE +" prefix for the value too.

 

Link to comment
Share on other sites

In your own code, whenever you are accessing ROM you have to make sure that you use the correct offset. Also for defines coming from DASM.

 

With Harmony this is offset 0x00000000, so it might not be easy to identify. 

Edited by Thomas Jentzsch
Link to comment
Share on other sites

32 minutes ago, Andrew Davie said:

@Thomas Jentzsch what do these files mean for Cubiks?  Other than dropping them in and compiling, what else needs to change for it to work on PlusCart? 

 

25 minutes ago, Thomas Jentzsch said:

In your own code, whenever you are accessing ROM you have to make sure that you use the correct offset. Also for defines coming from DASM.

 

With Harmony this is offset 0x00000000, so it might not be easy to identify. 

 

some of the functions defined in "defines_cdfj.h" take the offset :

 

  • setPointer

  • setPointerFrac

  • setIncrement

  • setIncrement2

  • ...

which means you shouldn't change the parameter when calling.

 

and some of them take the absolute value (mostly the MemCopy and MemSet ones) :

  • myMemset

  • myMemcpy

  • myMemsetInt

  • ...

 

which means you must prefix the parameter with "RAM_BASE +" (I don't think they are called with the ROM pointers), when you are using the defines from "defines_from_dasm_for_c.h"

 

Edited by Al_Nafuur
add defines_from_dasm_for_c.h
Link to comment
Share on other sites

31 minutes ago, Thomas Jentzsch said:

In your own code, whenever you are accessing ROM you have to make sure that you use the correct offset. Also for defines coming from DASM.

 

With Harmony this is offset 0x00000000, so it might not be easy to identify. 

Still confused. The following is ROM access, if table is a const array....

	int example = table[0];

Are you saying this needs to be modified to account for ROM offsets?

 

Link to comment
Share on other sites

2 minutes ago, Andrew Davie said:

Still confused. The following is ROM access, if table is a const array....


	int example = table[0];

Are you saying this needs to be modified to account for ROM offsets?

 

if "table" is one of your own const arrays in your c code, then you don't need to change it, because the compiler handled it according to the memory definitions in "custom.boot.lds"

 

 

  • Like 1
Link to comment
Share on other sites

This might help track down problem code when converting to the PlusCart.

 

In the video below, I'm running https://github.com/JetSetIlly/plusromtest_cdfj but without the fixes in main.c.

 

 

So, illegal accesses are looked up in the compiler's map file and illegal memory accesses and the function name are printed to the log.

 

I should be able to get more detail in there - it will mean changing the compiler options so that a detailed listing is produced but it would be worth it I think. In the meantime, this at least gives the programmer a clue as to where to begin.

 

Code pushed to:

 

https://github.com/JetSetIlly/Gopher2600/tree/v0.15.x

  

 

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

19 hours ago, JetSetIlly said:

I should be able to get more detail in there - it will mean changing the compiler options so that a detailed listing is produced but it would be worth it I think. In the meantime, this at least gives the programmer a clue as to where to begin.

 

I've come to an impasse with this. I would expect that compiling with the -g option would put the necessary debugging information into armcode.elf. However "objdump -S" produces incomplete interleaving of the Source Code. For example:

 

image.thumb.png.4478cf97af748f19fccf0b54d4a43c27.png

 

Any GCC for ARM experts around who might now what the missing ingredient is?

 

on edit: So it's identified the function blocks but not what's in the function. Compare to a C program that does objdump correctly:

 

image.thumb.png.86889ef2f3adec6f19eeb2874c98ebb9.png

Edited by JetSetIlly
Link to comment
Share on other sites

12 minutes ago, Thomas Jentzsch said:

Stupid question: What is incomplete here?

After compiling with the -g option, running objdump -S on the resulting elf binary should output the disassembly (including the bytecode).

 

The disassembly should be commented with the source code that is responsible for the assembly. We can then use this file to produce more useful debugging information - for example, if there is an illegal access at PC 0x2000093c, we can say that this happened in SpashOverScan() function and give the exact line number in the source file.

 

However, in this instance, the detailed source code information doesn't seem to be included in the compiled object.

Edited by JetSetIlly
Link to comment
Share on other sites

1 hour ago, JetSetIlly said:

After compiling with the -g option, running objdump -S on the resulting elf binary should output the disassembly (including the bytecode).

 

The disassembly should be commented with the source code that is responsible for the assembly. We can then use this file to produce more useful debugging information - for example, if there is an illegal access at PC 0x2000093c, we can say that this happened in SpashOverScan() function and give the exact line number in the source file.

 

However, in this instance, the detailed source code information doesn't seem to be included in the compiled object.

Could it be that optimisation is interfering with the alignment?

I believe optimisation is a subsequent pass, which will destroy the associations to source lines.

 

Link to comment
Share on other sites

19 minutes ago, Andrew Davie said:

Could it be that optimisation is interfering with the alignment?

 

It's a good thought but I don't believe optimisation is the cause of this. The source information should still be present, although it might be misleading due to the optimisations.

 

For comparison, a regular C program (for Intel CPUs) compiled with gcc when compiled with -Os, will retain the debugging information.

 

Also, compiling with -Og, which is an optimisation level specifically for debugging, doesn't work either.

 

Edited by JetSetIlly
Link to comment
Share on other sites

Cracked it. I was putting the -g option in the wrong place on the command line ?

 

Example makefile in my plusromtest_cdfj github. See the diff for what I have changed.

 

https://github.com/JetSetIlly/plusromtest_cdfj/commit/b2a8baf0c07656e11a112144ed5b8ef0c610f6f2#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52

 

Running Gopher2600 will now print the source code relating to the access error. No line numbers yet - I'll have to investigate that further. But even in the current state, I think this will be very useful.

 

image.thumb.png.d591d8d5a2f9e9260fde618f25f0e4d1.png

 

And a video:

 

 

 

  • Like 1
Link to comment
Share on other sites

Got Cubix running in Stella using STM32F addresses. I did not change Andrew's code at all, just used the attached fixed files.

 

It doesn't work in gopher2600 though. So one of the emulators must be wrong. :) 

cubiks.bin

defines_cdfj.h custom.boot.lds custom.S

Edited by Thomas Jentzsch
  • Like 3
Link to comment
Share on other sites

1 hour ago, Thomas Jentzsch said:

Got Cubix running in Stella using STM32F addresses. I did not change Andrew's code at all, just used the attached fixed files.

 

It doesn't work in gopher2600 though. So one of the emulators must be wrong. :) 

cubiks.bin 32 kB · 2 downloads

defines_cdfj.h 5.89 kB · 0 downloads custom.boot.lds 1.67 kB · 0 downloads custom.S 1.59 kB · 0 downloads

 

Nice work.

 

It's fine in Gopher2600. The preferences file needs to be manually changed to:

 

hardware.arm7.model :: STM32F407VGT6

 

on edit: changes for the .map and objdump file support is in the v0.15.x branch.

 

https://github.com/JetSetIlly/Gopher2600/tree/v0.15.x

Edited by JetSetIlly
  • Like 2
Link to comment
Share on other sites

One thing we still need to figure out is how the STMF32 differs to the LPC2000 internally. We now understand the memory model differences I believe, but there are still questions about the timer and whether there is a MAM and/or how it works in the STMF32.

 

In the meantime, I believe we can auto-detect differences between the memory models quite easily.

 

Auto-detection of what model a CDF binary is targetting can be done through inspection of 0x863 and 0x867:

        if data[0x863]&0x20 == 0x20 && data[0x867]&0x20 == 0x20 {
            memModel = memorymodel.PlusCart
        } else {
            memModel = memorymodel.Harmony
        }

 

And similarly for DPC+ the differences are in 0xc4b and 0xc4f:

        if data[0xc4b]&0x20 == 0x20 && data[0xc4f] == 0x20 {
            memModel = memorymodel.PlusCart
        } else {
            memModel = memorymodel.Harmony
        }

 

There are other differences but these are the ones I'm using.

 

Edited by JetSetIlly
  • Like 3
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...