Skip to content

Conversation

@vananasun
Copy link
Contributor

@vananasun vananasun commented Sep 30, 2025

Important:

  • I haven't been able to test writing yet, because I ran into code size issues and I think that corrupted the stack, and then corrupted my SD card file system. So currently the driver works as read-only.
  • Needs a header called macros.h but that's merely to define the macro DEBUG_LOG.
  • Requires FatFS to be put in cpu/lib. Delete ffconf.h as it's already in my PR.
  • Requires am18x-lib into cpu/lib, we have to include our own am18x_conf.h with _MMCSD not defined, or we could choose to fork am18x-lib and/or integrate it into am1802-csl fork.
  • EDMA3 support has yet to come ofcourse (let's rip just the peripheral code from am18x-lib)

I wrote a test function in main.c

Sorry for messyness or potentially unnecessary code that might've slipped in. I hope soon we can integrate all these drivers cleanly into main branch once we have a functioning bootloader (#40) that allows for bigger code size and continue developing nice and clean. Proper serial console and error handling interface would reaally be nice to have now

@enorrmann
Copy link
Contributor

enorrmann commented Oct 16, 2025

Hi ! I'm trying to compile this branch, but no luck so far, I cloned
https://github.com/abbrev/fatfs
https://github.com/turmary/am18x-lib
into libs and created
cpu/src/kernel/macros.h as

#ifndef MACROS_H
#define MACROS_H

//#define DEBUG_LOG 1
#define DEBUG_LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
#endif

also commented out

//#define _MMCSD
#define _MMCSD0
#define _MMCSD1

edit: changed DEBUG_LOG to

#define DEBUG_LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)

but I'm getting lots of
In file included from src/kernel/device/dev_sdcard.c:41:
src/kernel/device/sd_protocol.h:136:5: error: unknown type name 'uint8_t'
136 | uint8_t RES_TEST_MODE :2;
| ^~~~~~~

@bangcorrupt
Copy link
Owner

error: unknown type name 'uint8_t'

Probably need #include <stdint.h> in sd_protocol.h, but I haven't tried this code myself yet.

@bangcorrupt
Copy link
Owner

I think you could copy macros.h from the ipc-driver-2 branch.

@enorrmann
Copy link
Contributor

yes , I tried including stdint but then it conflicts with
./lib/am18x-lib/inc/am18x_type.h:19:41: error: conflicting types for 'uint32_t'; have 'unsigned int'
the i tried defining __USE_STDINT_H

#ifndef __AM18X_TYPE_H__
#define __AM18X_TYPE_H__

#define __USE_STDINT_H

#ifdef __USE_STDINT_H
#include <stdint.h>

to avoid the conflict and that seems to work but now it can't find RTOS
src/main.c:43:10: fatal error: FreeRTOS.h: No such file or directory
43 | #include "FreeRTOS.h"
| ^~~~~~~~~~~~

@bangcorrupt
Copy link
Owner

bangcorrupt commented Oct 16, 2025

As far as I can tell FreeRTOS isn't used in this PR, so you can probably just delete that #include and the one for task.h beneath it. Otherwise you need the FreeRTOS code in the cpu/lib directory.

@vananasun
Copy link
Contributor Author

yes , I tried including stdint but then it conflicts with ./lib/am18x-lib/inc/am18x_type.h:19:41: error: conflicting types for 'uint32_t'; have 'unsigned int' the i tried defining __USE_STDINT_H

#ifndef __AM18X_TYPE_H__
#define __AM18X_TYPE_H__

#define __USE_STDINT_H

#ifdef __USE_STDINT_H
#include <stdint.h>

to avoid the conflict and that seems to work but now it can't find RTOS src/main.c:43:10: fatal error: FreeRTOS.h: No such file or directory 43 | #include "FreeRTOS.h" | ^~~~~~~~~~~~

Yes just delete freertos header.
I dont know what the stdint error is quite yet, but I can tell you I probably changed some basic header stuff temporarily to make my code work. Nothing big but your issue is likely such an occurrence

@bangcorrupt
Copy link
Owner

I dont know what the stdint error is quite yet

am18x-lib has __USE_STDINT_H defined in am18x_conf.h so it will use the typedefs in stdint.h instead of those in am18x_type.h

Can you tidy up this PR so it builds and doesn't include unnecessary code please? There is no rush, I'm not sure when I'll be able to review it.

@enorrmann
Copy link
Contributor

any progress on this @vananasun ? it would be very useful at this point to have at least ro access to sd card

@vananasun
Copy link
Contributor Author

any progress on this @vananasun ? it would be very useful at this point to have at least ro access to sd card

Unfortunately not (yet), I've been very busy with life including preparing to move apartments. I kind of lost hope trying to attach a debugger, but ordered a chip to program the flash a few days ago. My idea is to write a pause in the flash boot code of my E2 so I can attach a debugger and then finally continue development.

If you are keen and impatient however, I will have you know that this PR has functioning read functionality already! Caveats are:

  • codebase is still messy, with the am18xlib headers and all
  • the big issue with all these driver pull requests is that they're too big for freetribe's currently temporary memory layout. The next step forward has to be a proper bootloader (read the Bootloader Discussion)

Hope i didn't get ur hopes down

Cheers,
Maxim

@bangcorrupt
Copy link
Owner

too big for freetribe's currently temporary memory layout

dev branch executes from DDR.

#54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants