Author Topic: Memory model for Microcontrollers  (Read 7538 times)

0 Members and 2 Guests are viewing this topic.

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Memory model for Microcontrollers
« Reply #25 on: May 01, 2024, 12:59:56 pm »
I apologize if I'm struggling to grasp the concept. I am trying my best I genuinely want to learn and appreciate any guidance or explanations provided. Please feel free to share your insights or suggestions on how I can improve my understanding. Thank you for your patience

You do not struggle with anything, cause you're a bot.

A person that wants to learn, shows a totally different pattern. Asks specific questions, follows up on explanations.
The topics that you start are way too broad. So different all the time. Questions are never specific. And you never seem to learn anything, years after you asked.

It's a shame to see people reply. Well, maybe there is a merit to it, as other engineers may learn reading those threads.
Very discouraging comment.

Learning can be a gradual process, and everyone has their own pace and approach. I am trying my best if you have suggestions for improvement, I'm open to hearing them.
« Last Edit: May 01, 2024, 01:03:45 pm by Kittu20 »
 

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 6874
  • Country: va
Re: Memory model for Microcontrollers
« Reply #26 on: May 01, 2024, 02:07:15 pm »
Since quite a few users thing you're a bot, perhaps you could post something to show that you're not. A screencap from your PC of this thread, perhaps, or stamped photo of something you're working on.
 
The following users thanked this post: tooki, Kittu20

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Memory model for Microcontrollers
« Reply #27 on: May 01, 2024, 02:43:40 pm »
I have a many screencap photo to share. I am attaching few of them
« Last Edit: May 06, 2024, 01:12:23 pm by Kittu20 »
 

Offline tellurium

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: ua
Re: Memory model for Microcontrollers
« Reply #28 on: May 01, 2024, 03:55:41 pm »
Arduino "screen capture" is from https://forum.arduino.cc/t/arduino-based-traffic-light-system/1144573
st-link and terminal "captures" are also not a captures, but images from internet.

I guess it is fine when people talk to bot. I just don't like being deceived that I talk to a person.

Open source embedded network library https://github.com/cesanta/mongoose
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Memory model for Microcontrollers
« Reply #29 on: May 01, 2024, 04:14:02 pm »
Don't you think we are moving from the main issues of the thread? By the way, I shared the photos that were on my mobile, and I have many other pictures as well
 

Online MK14

  • Super Contributor
  • ***
  • Posts: 4577
  • Country: gb
Re: Memory model for Microcontrollers
« Reply #30 on: May 01, 2024, 04:24:33 pm »
Don't you think we are moving from the main issues of the thread? By the way, I shared the photos that were on my mobile, and I have many other pictures as well

EDIT:
I didn't realize the picture was perhaps put in, in jest, or for similar reasons.  As later posts in the thread, would seem to indicate.

At least one of the pictures, seems to trace through to an AI bot centre, or similar.



Here:
https://www.neosofttech.com/services/artificial-intelligence-machine-learning/

« Last Edit: May 01, 2024, 06:42:32 pm by MK14 »
 

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Memory model for Microcontrollers
« Reply #31 on: May 01, 2024, 04:34:43 pm »
Oh come on, after reading the rest of the comments, I couldn't resist. So , I got up and now I'm clicking and sending pictures of whatever electronic items I have.

It's ridiculous, man! It feels like I'm being accused and standing in  court
 
The following users thanked this post: MK14

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 6874
  • Country: va
Re: Memory model for Microcontrollers
« Reply #32 on: May 01, 2024, 04:43:01 pm »
Quote
It's ridiculous, man! It feels like I'm being accused and standing in  court

Well, you were!

But nicely played  ;)
 
The following users thanked this post: MK14

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3782
  • Country: nl
Re: Memory model for Microcontrollers
« Reply #33 on: May 01, 2024, 07:54:18 pm »
Oh come on, after reading the rest of the comments, I couldn't resist. So , I got up and now I'm clicking and sending pictures of whatever electronic items I have.

It's ridiculous, man! It feels like I'm being accused and standing in  court

I'm missing today's newspaper on the background to really prove it is your electronics stuff on the floor.  :-DD

And what tellurium did not seem to notice is that it is your post on the arduino forum. So for an alleged bot you do come around.  :popcorn:

Offline jnk0le

  • Contributor
  • Posts: 48
  • Country: pl
Re: Memory model for Microcontrollers
« Reply #34 on: May 01, 2024, 09:07:02 pm »
Lооkѕ lіkе ѕоmеоnе іѕ trоllіng wіth АІ ѕраmbоt ѕіmіlаr tо GРТ-4сhаn but thіѕ tіmе сараblе оf роѕtіng іmаgеѕ аnd lеѕѕ blаtаnt.

mѕg5090590 іѕ раrtісulаrlу ѕuѕ - thіѕ іѕ nоt еvеn а сорураѕtе frоm аttасhеd dаtаѕhееt, еvеn
lеѕѕ а роѕt рrоduсеd bу "lеаrnіng nеwbіе", but ехасtlу whаt сhаtgрt wоuld hаlluсіnаtе.

Oh come on, after reading the rest of the comments, I couldn't resist. So , I got up and now I'm clicking and sending pictures of whatever electronic items I have.

It's ridiculous, man! It feels like I'm being accused and standing in  court

Тhеу аѕkеd уоu tо роѕt а ѕсrееnѕhоt оf thіѕ thrеаd, nоt а rаndоm іmаgеѕ. Іf уоu аrе unаblе thеn  Could you tell us why apples are bigger than dogs? This should help us solve your issue with memory model.
« Last Edit: May 01, 2024, 09:17:58 pm by jnk0le »
 

Offline tellurium

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: ua
Re: Memory model for Microcontrollers
« Reply #35 on: May 01, 2024, 09:09:58 pm »
I am not convinced at all.
People that REALLY want answers to their questions, behave differently. They ask, they double-check, they engage.
That thing, Kittu, does not do that.
Even on that Arduino post - not a single follow up. Even when asked a concrete question, a very vague, non-concrete answer was given.

As it was pointed out, he asked the same question years ago in https://www.avrfreaks.net/s/topic/a5C3l000000BqGsEAK/t391526
And what? Not a single follow up on that thread.
Do I believe  in the "It was different, I want to learn more" nonsense? I don't.

Anyhow, I don't want to waste any more time on this. If you guys want to entertain the bot, your choice.
« Last Edit: May 01, 2024, 09:13:06 pm by tellurium »
Open source embedded network library https://github.com/cesanta/mongoose
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 

Online MK14

  • Super Contributor
  • ***
  • Posts: 4577
  • Country: gb
Re: Memory model for Microcontrollers
« Reply #36 on: May 01, 2024, 09:31:33 pm »
(As already mentioned) In the following thread:
https://www.eevblog.com/forum/microcontrollers/larger-and-more-complex-embedded-systems/msg5072800/#msg5072800

Kittu20, seems to admit to using AI (ChatGPT etc), to formulate the questions, which perhaps explains why they appear to be a bot, even if they aren't.

I've asked  questions because I'm genuinely curious and eager to understand a particular concept. English is not my first language, so I used AI to  format my question. However, I know that ChatGPT can't replace the real-time work experience and expertise that individuals in the industry have earned through their careers.

So, it perhaps is no surprise, why so many people seem to think they are a bot.
 

Online MK14

  • Super Contributor
  • ***
  • Posts: 4577
  • Country: gb
Re: Memory model for Microcontrollers
« Reply #37 on: May 02, 2024, 10:55:52 am »
I suspect, using ChatGPT to formulate your posts.  Distorts, changes and hides, potentially important details about the REAL question, being asked.

Hindering, people who want to help you.

Sometimes, a person asking questions, really needs help in different areas.  But, this 'ChatGPT' way for posting questions, in a thread, removes such important information.

Also, it seems to make your questions, look like they come from a BOT, which means some people will then ignore the question and possibly you as a user, as a result.
 

Offline tellurium

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: ua
Re: Memory model for Microcontrollers
« Reply #38 on: May 02, 2024, 12:55:36 pm »
Sure. An embedded engineer (from India!) does not know English.
Open source embedded network library https://github.com/cesanta/mongoose
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 
The following users thanked this post: MK14

Online MK14

  • Super Contributor
  • ***
  • Posts: 4577
  • Country: gb
Re: Memory model for Microcontrollers
« Reply #39 on: May 02, 2024, 12:59:43 pm »
Sure. An embedded engineer (from India!) does not know English.

I agree, there seems to be something 'funny' going on.  But I'm not sure, exactly what.

Vague guesses, would be they don't want others, to know who they are, as they are putting questions arising from their job, e.g. Automotive related.
They could be trolling.
Maybe it is some kind of 'bot' operation, with some (possibly) human, intervention, from time to time.

Their posts, just don't seem 'right'.
 

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Memory model for Microcontrollers
« Reply #40 on: May 02, 2024, 01:34:24 pm »
Sure. An embedded engineer (from India!) does not know English.

I think you are a bot that is trolling me here in a bad way. I've previously requested that you stick to the thread topic, but you repeating same things and I never said I don't know English; I simply mentioned that I'm not good in it. If you can't help someone, you shouldn't discourage them either. Everyone has their self-respect. You may be intelligent, but I am not, which is why I ask questions that I believe should be asked, but there's nothing beyond self-respect
 

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 114
  • Country: in
Re: Memory model for Microcontrollers
« Reply #41 on: May 02, 2024, 01:47:42 pm »
Now I come back to the original question. I think memory layout is relevant for target devices like PC and ARM but not for 8051 and PIC microcontrollers. I need to look to MAP file.The map file shows a summary of all memory usage, including the locations of variables and functions.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3782
  • Country: nl
Re: Memory model for Microcontrollers
« Reply #42 on: May 02, 2024, 02:06:10 pm »
Now I come back to the original question. I think memory layout is relevant for target devices like PC and ARM but not for 8051 and PIC microcontrollers. I need to look to MAP file.The map file shows a summary of all memory usage, including the locations of variables and functions.

Depends on whom are working on the project. If it is just you, then you should know about the variables and buffers being used in the code. When using third party libraries it becomes a different story. Depends on availability of source code or not.

Furthermore it boils down to the tools that are available. With .elf files you can extract a lot of information with the different tools. I myself hardly use these kind of tools, because most of what I do is based on my own code, and for that I know what the variables are, and I don't care where they are in the actual memory, not until something does not work as expected and you need to debug.

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 3735
  • Country: gb
  • Doing electronics since the 1960s...
Re: Memory model for Microcontrollers
« Reply #43 on: May 02, 2024, 09:58:19 pm »
Quote
I agree, there seems to be something 'funny' going on.  But I'm not sure, exactly what.

This is a difficult topic because there are huge numbers of real people who are making postings purely to kick off discussions. The questions may come from ChatGPT or some such but the real person is present to deal with whatever fallout takes place.

I run a tech forum (not electronics) and even though I am intimately familiar with the subject there, I sometimes struggle with this when somebody manages to start a thread which then continues into some good responses. Most people recognise when this is happening and don't bother to respond, but it varies.

Why they do it is a mystery. It is believed to be to generate text for ChatGPT etc (ChatGPT is no "AI" - it is just a very good piece of code which does statistical analysis on vast amounts of text, and it needs lots of relevant human-produced text to work) but as far as anyone knows they are not getting money for this. I guess not having a life is as good an explanation as any. On my site we had a guy who literally spent 16hrs/day on his Ipad, generating thousands of posts per month. He ran multiple personas too... including a female which was a clever tactic because women get tons of engagement (a variation of the ancient "damsel in distress" method, which always works) in any male dominated community.

If I was a mod I would delete any question posts which are just seeking to generate generic essays, but it is hard to do this when a) there are good responses by the time the mod sees it and b) the forum runs adverts which obviously need to generate clicks. Adverts are the big problem but that's another story...
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 
The following users thanked this post: newbrain, MK14

Online MK14

  • Super Contributor
  • ***
  • Posts: 4577
  • Country: gb
Re: Memory model for Microcontrollers
« Reply #44 on: May 02, 2024, 10:17:08 pm »
Quote
I agree, there seems to be something 'funny' going on.  But I'm not sure, exactly what.

This is a difficult topic because there are huge numbers of real people who are making postings purely to kick off discussions. The questions may come from ChatGPT or some such but the real person is present to deal with whatever fallout takes place.

I run a tech forum (not electronics) and even though I am intimately familiar with the subject there, I sometimes struggle with this when somebody manages to start a thread which then continues into some good responses. Most people recognise when this is happening and don't bother to respond, but it varies.

Why they do it is a mystery. It is believed to be to generate text for ChatGPT etc (ChatGPT is no "AI" - it is just a very good piece of code which does statistical analysis on vast amounts of text, and it needs lots of relevant human-produced text to work) but as far as anyone knows they are not getting money for this. I guess not having a life is as good an explanation as any. On my site we had a guy who literally spent 16hrs/day on his Ipad, generating thousands of posts per month. He ran multiple personas too... including a female which was a clever tactic because women get tons of engagement (a variation of the ancient "damsel in distress" method, which always works) in any male dominated community.

If I was a mod I would delete any question posts which are just seeking to generate generic essays, but it is hard to do this when a) there are good responses by the time the mod sees it and b) the forum runs adverts which obviously need to generate clicks. Adverts are the big problem but that's another story...

Thanks!
That is an excellent response.

Not being able to see the (hopefully) real people, who started a thread.  Combined with also not knowing how much time and effort the original poster made, beforehand to answer the question(s) themselves, makes it rather tricky to know how to react.

There are so many (freely in most countries), resources available, through search engines, Wikis and a huge range of books, some free, some library or purchase only.  So the obvious question of why they didn't use those resources, instead, also comes to mind.

Modern forums (just how you described), can provide a very quick and easy (lazy), way for someone with unsound motivations, e.g. trolling, they are bored, or they just like making threads (it gives them 'kicks'), for whatever reason(s).  Can seem rather unfair, as a troll can create a partly silly, time wasting question, in a matter of minutes (or less, even).

Causing others to waste time (in some but NOT all cases), responding to those threads or posts.

It must be stressful, being a moderator, and having to decide, when to take no action, give a vacation (temporary ban, or other such things), or ban them, for a while or permanently.

(As regards this thread) I suppose, it might not be out of malice, or related to ChatGPT/bots, but just be, that they perhaps need to consider improving the quality of their thread starting (opening) question(s).

Otherwise, we could write a book load (quite literally), of replies, and still completely NOT answer the real intended question(s).
 

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 6874
  • Country: va
Re: Memory model for Microcontrollers
« Reply #45 on: May 02, 2024, 10:34:38 pm »
Quote
If I was a mod I would delete any question posts which are just seeking to generate generic essays, but it is hard to do this when a) there are good responses by the time the mod sees it

If the questionable post generates good responses, isn't that what a forum is supposed to be about? Does it really matter what started it if there is proper engagement between posters, and people learn something they otherwise might not?

It had crossed my mind that maybe Dave was behind this, seeking to distract from SMPU employment, water power and similar recurring subjects :)
 

Online MK14

  • Super Contributor
  • ***
  • Posts: 4577
  • Country: gb
Re: Memory model for Microcontrollers
« Reply #46 on: May 02, 2024, 10:48:22 pm »
If the questionable post generates good responses, isn't that what a forum is supposed to be about? Does it really matter what started it if there is proper engagement between posters, and people learn something they otherwise might not?

I still don't like the idea, of possibly poorly written questions and/or bots and/or trolling.  Creating the thread, in the first place.

But you are right.  It can in some cases, lead to rather interesting and education threads, as a result.
 

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 6874
  • Country: va
Re: Memory model for Microcontrollers
« Reply #47 on: May 03, 2024, 09:39:47 am »
Yes, my first thought is that it is wrong, but perhaps that's the emotional impact of feeling conned. There is a difference between someone giving you $5 because they won $100 and want to share their good fortune, and giving you $5 because their mates dared them go near that homeless **** and then laugh about it afterwards. In both cases you get $5 but you'd perhaps appreciate it more in the first case.
 
The following users thanked this post: MK14

Online MK14

  • Super Contributor
  • ***
  • Posts: 4577
  • Country: gb
Re: Memory model for Microcontrollers
« Reply #48 on: May 03, 2024, 10:23:15 am »
Yes, my first thought is that it is wrong, but perhaps that's the emotional impact of feeling conned. There is a difference between someone giving you $5 because they won $100 and want to share their good fortune, and giving you $5 because their mates dared them go near that homeless **** and then laugh about it afterwards. In both cases you get $5 but you'd perhaps appreciate it more in the first case.

Unfortunately, as I see it.  There is a technical danger, from an engineering knowledge point of view (in my opinion).  With allowing, trolling and/or made up questions and/or too general, unspecific, created questions etc.

Which is, that with 'real' questions, created from current real life issues.  Such as, why does my circuit oscillate?

Because, then, we can spend our engineering resources, solving the actual, real life problems and issues, that actually really occur.

But completely made up questions.  Can create situations, which don't really exist, and neither do the problems, posed by such questions.

E.g. Why have I caught a virus infection, from my upstairs neighbor, from him using a secret, micro-wave, fiddly-sticks, memory mapped, ray gun at me, and how does he know where I'm located, at any given time?
Plz hlp!

But the thing is, it is (almost certainly) just the imagination of the OP's, possibly mentally ill state of mind (or trolling and/or technical misunderstandings), rather than a real, proper technical question.  Probably mentioning, a number of things, which are not technically feasible or possible.
 

Offline tellurium

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: ua
Re: Memory model for Microcontrollers
« Reply #49 on: May 03, 2024, 02:58:58 pm »
For those who'll read this thread - IMO the explanation by Nominal Animal is the most complete, I am talking about https://www.eevblog.com/forum/microcontrollers/memory-model-for-microcontrollers/msg5478241/#msg5478241
However I think it is a bit advanced. I'll take the liberty to put Nominal Animal's explanation in simple terms.

Assume we take STM32 ARM microcontrollers as hardware, and GCC as a toolchain.
The microcontroller's memory has many regions, and simply speaking, there are:
a) flash region: contains firmware code. You can read bytes from that region as if it is a simple RAM , but writing to that region is a complex procedure.
b) RAM region: you can read and write anything there
c) peripheral controllers: memory-mapped IO. reading and writing to that memory produce special effects depending on a controller. For example, writing to a specific place inside a GPIO controller may turn GPIO pin (e.g. LED) on or off.


|-------[   FLASH   ]--------[  RAM  ]----------------------[ GPIOA ]--[GPIOB]---[ other periperals controllers....]------|


So, that's what hardware defines. There is no .text, no .heap, nothing like that. Just those memory regions, and if you manage to create a firmware code - a .bin file, and write it to flash, that's all what matters. An MCU starts executing that code from the FLASH region, and the code can access RAM and peripherals, that's it.

Now, you can use different programming languages / compilers to produce a firmware binary.  If you use C, then your program is, simply speaking, a set of functions and variables. For example, this:

Code: [Select]
static int led_state;   // A variable. Goes to the RAM region.

void toggle_led(void) {      // A function. Goes to the FLASH region
  GPIOA->BSRR |= ..... led_state ...  //  A piece of code that accesses a variable from RAM region, and a controller in GPIOA region
}

int main(void) {
  ....
  toggle_led();
}

The task of the toolchain is to produce a firmware binary. Inside the binary, as it stated above, there are no notions of .text/.heap/.data. Only machine codes, and data pieces at specific addresses.
So how the toolchain produces that binary? There are several steps:

a) GCC compiler compiles your code into the object files. Object files have ELF format. That format specifies so-called sections. Code (functions) go into the .text section. Data (variables) go into the .data section. Node that other languages can also produce ELF, so this is not really C specific.
b) Produced object files linked together by a linker to produce an output firmware.elf file. A linker uses a "linker script" file that has instructions like this: "put .text section to the memory region that starts at 0x8000000, and .data section at memory region that starts at 0x20000000". Of course, 0x8000000 is FLASH region, and  0x20000000 is RAM region. That's the place where ELF sections are mapped to the hardware memory regions.
c) An "objdcopy" tool extracts .text and .data sections from firmware.elf and concatenates them into firmware.bin. So essentially firmware.bin file is a collection of all functions, followed by all variables.

That's it!

Now, if you look closer, then you see that GCC would need to create two functions from the above examples: main() and toggle_led(). So in the FLASH memory, there will be a main() code, followed by the toggle_led() code (or vice versa). Likewise, for variables, there is a int variable "led_state" that needs to go into the RAM section. If there are more variables defined by the program, they will be placed in the RAM region one after another.
That's what they call a compile-time allocation. When a linker is done with arranging functions and variables to appropriate places, it generates the .map file if the appropriate build flag is given.

When all variables are placed in RAM, there is a free RAM space left. That will be heap. And at the very end of RAM region there is stack. So if we magnify RAM region, we'll see something like this:


---[led_state|var2|var3|...|end|  HEAP--->                          <-- STACK]-------
   |<--------------------------------- RAM --------------------------------->|


Usually linker scripts mark the end of all variables with a special symbol "end", so that the malloc function may know where heap starts. Also from the linker script file, it knows where RAM ends, and what's the maximum configured stack size. That's how malloc knows its boundaries.


This is my understanding of the memory model works, and its interaction with ELF sections. Note that this description is simplified, I've omitted a bunch of stuff like vectors, startup code and .data relocation, BSS, etc etc.
« Last Edit: May 03, 2024, 06:27:28 pm by tellurium »
Open source embedded network library https://github.com/cesanta/mongoose
TCP/IP stack + TLS1.3 + HTTP/WebSocket/MQTT in a single file
 
The following users thanked this post: MK14, eutectique, Kittu20


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf