Orange Pi
Tristan M. (2946) 1039 posts |
If nothing else works, start again. There’s still something pointing to the OMAP3 HAL that I have to find. Back to the logs I guess. If there’s a bright side, I noticed OMAP3 uses EHCI. So does the H3. |
Tristan M. (2946) 1039 posts |
No progress with the proper build system HAL however I did find one hell of a pitfall to watch out for. I started fresh as stated before. Went through and edited the files. So I’ve re-made or re-edited the files, and have a build running right now hoping to see it fail because the HAL is kind of empty rather than not being able to find whatever.OMAP3 which has been stopping me dead for weeks. e: I suspect some of the frustrations with processor type not changing and other quirks like complaining about the modules file pointing to the wrong place are all due to the same core issue. It may be time that I set up an ADFS USB stick for building on, because something just isn’t right. |
Jeffrey Lee (213) 6048 posts |
I think some of the generated dependency information that’s added to makefiles uses the full paths of files. So if you rename a source tree after doing a (partial) build you might end up with a bunch of “file not found” errors (this won’t explain why your files got deleted, but it’s something to be wary of in future). Also another thing to be wary of is that the build system does make copies of some of the files – e.g. castle.BuildSys, mixed.Library, etc. all get copied to the root of the tree (and used from there). So if you’re editing files you need to make sure you edit the right ones, and if you’re diffing against a clean copy of the source tree (e.g. straight from CVS or a source archive) you need to make sure to have your changes in both locations otherwise you’ll miss some of them.
Yeah, I’d say using an ADFS/FileCore formatted drive is the safest course of action. I don’t think anyone really tests the build system on anything else, and for something like DOSFS/Fat32FS you may find that stuff breaks in subtle ways due to e.g. some file attributes not being fully supported. Historically there was also a bug in the build system (probably in amu?) where it failed to work correctly if files built too quickly (timestamp granularity issue); the fix that was applied works for filesystems with centisecond accuracy like FileCore but I’m not sure if it’s guaranteed to work with FAT which only stores modification times with 2s granularity. |
Michael Grunditz (467) 531 posts |
I didn’t rename the tree , just added a new target. |
Tristan M. (2946) 1039 posts |
After renaming the tree from OMAP3 to AWH3 I re-ran the prepare script. I also remove the old entry from the builder and add a new one. I also do the cleaning steps every time with the build because of the potential for things to get broken. I should add that I’ve had more iterations of doing various combinations of trees than I can remember. Definitely not saying that I have some kind of knowledge. Just empirically trying things to see what does and doesn’t work. The files disappearing was a new one for me… perhaps. .bq Historically there was also a bug in the build system (probably in amu?) where it failed to work correctly if files built too quickly (timestamp granularity issue) What an odd bug. It just occurred to me that I’ve been building ROMs fine for the Pi for months on fat32fs.
That one’s already caught me out. Took me long enough to work out that the lesson stuck.
It doesn’t seem to matter much. Thankfully the build tree is set up with either relative structure or absolute with the root as an environment variable, or whatever it’s called in this context. I am thinking I’ll just go through with my earlier plan of just butchering OMAP3 for now, and trying to rename later. e: I’d forgotten how horribly slow it is to copy USB to USB on an RPi. Got a USB stick formatted, OMAP3 tree uncompressed, populated with tools and scripts run. Glad I didn’t need to use it for anything. Just checked in on it every 1/2 hour or so. e2: DDE’s !Find helped me find some stragglers. Finally got a new build target! One of the issues was I’d missed a line in castle.blahblahblah.ModuleDB Now there’s a working target I can start cobbling together something using the preexisting framework. I’m going to aim to see something spat out from the UART by the end of the week. Simple goal. Is FileCore slower than FAT? It feels it. Doesn’t matter. It doesn’t mess with the cases of the characters in the filenames unlike FAT. |
Tristan M. (2946) 1039 posts |
I’ll be honest. Step 4 in the not quite 10 step plan is my downfall. Or rather this part:
I know how to edit these files. It’s this bit “Add the test program into the RISC OS build system” that I don’t get. It’s a little nebulous. Is there an example anywhere of this part of the step and the building / execution? Tickling he hardware the right way to do this is dead easy. I’ve done it a few different ways in fact. But how do I do it in relation to the framework? I’m not sure what’s required of me here. As I’ve stated I’m also writing a standalone “fantasy” HAL using GCC with header files containing what I believe to be correctly laid out functions for the HAL (Thanks OMAP4 devs). Unless there’s a way of using it directly, it’s more of a template of how to get bits of hardware up and running. Last night I had a quick hunt around and found the H5 user manual. After having a look through it, it would seem that if an H3 (A7) version could be made to work, an H5 (A8/A53) would probably work by mostly just having it’s memory map tweaked, which would be nice. |
Michael Grunditz (467) 531 posts |
Why don’t you copy a target and change it to your need. You can definitely create something in s.Top that you can test with. Just leave everything else as is. Oh you are using GCC. Well I still don’t understand why you reinvent the wheel, you can do that later. |
Jeffrey Lee (213) 6048 posts |
If I was to start a port to a new platform called Wibble, I’d add support for Wibble by performing the following steps:
The stuff relating the the Products file/folder is only relevant for CVS, so there’s no need to do that if all you’re interested in is getting code building. There’s a pre-requisite for this that isn’t explicitly mentioned: your test program must have a makefile that provides the different rules/targets that the build system uses. For a HAL the two most important ones would be ‘rom’ (build the HAL) and ‘install_rom’ (copy the binary as ‘${INSTDIR}.${TARGET}’). Since nobody’s written a HAL using GCC before, you may have to work out the makefile rules yourself (or you can try building the code using the DDE + CModule makefile, like the other HALs do) |
James Wheeler (3283) 344 posts |
GPL is a terrible license and I wont go near GPL code. (Not that Castle’s license is much better) I love open source, but always favoured a BSD-style license and all code I’ve published is BSD.
Absolutely. Reverse engineering is fair use under copyright law. Problem is manufacturers make it difficult with binary blobs and other just ignore GPL license and fail to comply in providing the full source. |
Chris Evans (457) 1614 posts |
I hesitate to suggest it, in case I’m misunderstanding things or it is obvious but I’d add step 11 I expect builds have the build name imbedded in the binary so initially make the name wibble the same length! |
Jeffrey Lee (213) 6048 posts |
That’s step 5 of the not-quite-ten-step plan :-) |
Tristan M. (2946) 1039 posts |
Jeffrey. The implicit step which you wrote at the end is what I was overlooking. As we say “If it were a dog it would’ve bit me!”. That reminds me… which Hdr files etc in the HAL part of the tree that HAL uses are used by other parts of the build system? If, and that’s a big IF I were to try to get a gcc HAL working with the actual ROM instead of a testbed, I’d probably need to port the format of some of those files and keep them synchronised The other major issue I could foresee is getting the HAL to talk to the rest of the ROM. I wouldn’t have a clue how to do that beyond hand stitching jump tables after build. Besides holes in my knowledge and that irritating issue on needing to assign a big wimpslot to gcc somehow, it’s very tempting to chain in the gcc makefile to the DDE makefile to generate the ROM Thankfully I still have the most recent revision of all the files you mentioned, including their duplicates in other parts of the tree (which was one of my stumbling points). Looks like I just need to gut the makefile and make a top.s or whatever to feed it. Chris re your step 11. If I were to try going the gcc route I’m not too worried. The binary is just a stripped arm-unknown-riscos file built without any supporting libraries, and it runs without issue on the H3 which is a very plain Cortex A7. It’s also why I recoiled in horror when I dug deeper into the OMAP code. By the way I also have no idea how to build things in Norcroft C without the runtime, hardwire the start address, program and data space, specify the stack, add stack overflow and interrupt handler functions, or use the _start entry point instead of main(). James, I have to agree. However unless someone feels like getting the Mali up and running there’s really no need to look at blobs. The LIMA project already has an at least partially working open Mali core anyway if anyone wanted that. I think it’s CedarX or something which is where access can be gained for all the H3’s nice video handling ability, so again not the Mali. I wouldn’t be messing with that either tbh. e: Forgot to add that last night I realised how to cut out most of the messing around for testing the binary. |
Jeffrey Lee (213) 6048 posts |
Headers that are shared with other components will get copied to the Export folder in the root of the build tree, by the “export headers” build phase (which is the export_hdrs makefile target). I don’t think there are any HALs that export their headers, but they do certainly rely on headers exported by the rest of the system (HALEntries, OSEntries, etc.)
Remember that the RISC OS version of GCC has ‘asasm’, which is compatible with objasm sources. So if you’re happy with ARM’s assembler syntax then there’s no particular need to use the GNU syntax. The only gotcha is that recent versions of asasm don’t allow you to specify a hard-float ABI in the ELF header, which causes problems linking with hard-float FPA code produced by GCC’s C compiler. But since the HAL is a standalone binary that gets concatenated to the rest of the ROM image, you should be able to sidestep this issue by using C compiler flags that are compatible with whatever objasm is hard-wired to.
The key to this is that:
Well consider this a reverse engineering task, but with a really good disassembler that magically provides you with the original source code of the binary you’re trying to disassemble ;-) The poor level of documentation for the OS and build system means that the people who are able to work things out for themselves are usually the ones who succeed.
It might be worth looking at the makefiles for some of the apps that are built using GCC. Using GCC with AMU is possible, the only tricky part is that the dependency files generated by GCC aren’t in a format which AMU is happy with, and so a perl script is used to re-format them (part of the GCCRules makefile fragment)
Examine the makefile for one of the HALs. Or just look at the commands that are executed in the build output.
There’s a reason why the HALs are mostly written in assembler – getting C to work within the constraints of the HAL can be pretty tricky. See Using C in assembler components for some more detail on this. Possibly GCC will handle this better than Norcroft, but it’s not something I’ve looked at in any detail. If you can’t get GCC to produce read-only, position-independent code, I’d be tempted to split the HAL into two distinct parts: the pre-MMU part (everything up to the OS_Start call) and the post-MMU part (which will contain HAL_Init and all the other HAL entry points called by the kernel). That way you should be able to give both parts different static base addresses (physical address for the pre-MMU part, logical address for the post-MMU part) and things should “just work”. |
Tristan M. (2946) 1039 posts |
So the size of this doesn’t blow out I’ll just respond to necessary bits. Believe me, I have taken it all in. You have answered pretty much everything I’ve needed to know. I’ve had literally no time this week to have a proper look at anything. I stole a few minutes just now to go through a disassembly of the GCC code that I’ve generated for my test.
That goes without saying. I think you have written most of the useful documentation on the build system. May I suggest that you take what you have written for me and add a version of it to the Wiki? It goes a very long way towards making it all a lot less mysterious.
This part was where things seemed a bit hopeless. Thanks for that useful information. e: The code generated looks position independent but something isn’t. Interestingly when executed from another address instead of spitting out “Hello World” it prints out a chunk of 0xff to the UART. So perhaps the print code is working but looking in the wrong place. I don’t know. Doesn’t really matter anyway. It’s just a test program. |
Jeffrey Lee (213) 6048 posts |
Done, I think. https://www.riscosopen.org/wiki/documentation/show/How%20to%20port%20RISC%20OS%20to%20new%20hardware |
Tristan M. (2946) 1039 posts |
That’s excellent! It makes working on porting a lot more accessible. No idea if I said but I did sort out a build target and got some code up and running the normal way. Using gcc is far more interesting though so that’s what I’ve been playing with. I think if I give ld a better command file the GCC code should be ROMmable. After quite a bit of playing around the disassembly looks relocatable. When the makefile is at least fixed enough not to die at the end I’ll try importing headers via that script. e: worked out some of the quirks involving the DDE make utility and the makefile functions properly now. Only real irritation is the gcc toolchain has inconsistent file name handling so I have to sort that again. I think the Linux port has some things to teach me so I’m going to dig around in that for a bit. |
Tristan M. (2946) 1039 posts |
Makefile is going well, but I’ve hit a small wrinkle with asasm. I redid a copy of the only assembly file from gas to asasm, however for reasons I can’t quite pin down the code from it goes into the linker (ld) and doesn’t come out the other end. It just silently disappears, and a binary is generated missing a means to start. The reason I decided to try was simply so I could use IMPORTed .hdr files in an easy way that has them near the beginning of the linked binary. Please correct me if I’m wrong. It’ll sure save me a lot of time. I think it should work fine, however I am less than totally confident. If it works, it should be relatively easy to construct a proper HAL in C, which could potentially make porting a little more accessible. I just want to clarify to people readin this in passing that the DDE suite is still needed. It’s just I can’t find a way to make Norcroft C work the way I want. |
Jeffrey Lee (213) 6048 posts |
Thoughts that come to mind:
I’ve never used ld directly before (only via the gcc frontend), and have never really messed with ldscripts, and don’t really know how asasm would fit into things (I guess the AREA would determine which ELF section the code gets placed into, but maybe it’s not a direct mapping?) |
Tristan M. (2946) 1039 posts |
Got it to build again! So I have: The only reason I have “Top.s” in gas format still is I’m terrible with asasm and I also haven’t tested the asasm version of “Top.s” post downgrade yet. |
Tristan M. (2946) 1039 posts |
In terms of progress towards booting RO I haven’t made it far. Seeing if I can get the asm / C framework running is the time consuming thing.
Does anyone ever wish it was possible to grab a program by the proverbial scruff of the neck and show it something? I know I do. I pretty much picked rom_checkedout_okat random to see if I could get things to play nice. Progressing slowly but surely. This is the most promising error so far. |
Jeffrey Lee (213) 6048 posts |
With objasm/asasm all symbols are private by default.
|
Tristan M. (2946) 1039 posts |
Jeffrey, Unfortunately I already had it set up like that. This is probably the first real chance I’ve had to look at the code since then. I’ve got a multi pronged approach going with multiple makefiles and a couple of targets. I’m trying to find approaches which work, and which method to use. |
Tristan M. (2946) 1039 posts |
I removed -soft-float from the asasm flags to trip up ld, because it’s not providing me with any useful hints on what’s happening to the asasm objects. I know ld works with asasm. One of the GCC examples does exactly that. Not sure what’s going on yet. |
Jeffrey Lee (213) 6048 posts |
No. You might be able to use some of the C header files (a lot of the ones that are generated from assembler hdr files are just a long list of numeric #defines), but that’s about it. It would probably be worth using something like objdump to check what the differences are between the gas and asasm object files. |
Tristan M. (2946) 1039 posts |
Whatever the difference is, it has some powerful magic. Nothing seemed particularly enlightening. A friend had a look at the HAL code and dumps and had some useful suggestions. In the end not much progress was made at the time but I had some things to think about. This morning I roughly tacked ld into the OMAP3 based Makefile so it’d spit out a link and ld version of the final linked file. Armed with a new linker script for ld and a new as yet unknown to me gcc flag I finally got ld to put Top.o at the beginning of the file! The Norcroft linked file still has the weird problem with failing to resolve two symbols properly in on epart of the file yet does it fine in another. 0×41000000 Is pretty arbitrary to be honest. I think it’s the default base address for loading the linux image with U-Boot. The ‘/’ used for objdump and objcopy is because they don’t seem to support the RO ‘.’. I just hardcoded them in for now. No need to be fancy. I have no idea how to deal with the area alignment complaint of the ARM linker.
|