ARM-software / tf-issues

Issue tracking for the ARM Trusted Firmware project
37 stars 16 forks source link

Allow setting LOG_LEVEL back to initial compile time value #624

Closed iq250vip closed 6 years ago

iq250vip commented 6 years ago

In this issue and the corresponding commit, we allowed the user to dynamically set the log level. This is a very useful feature, but you can only set the log level to a level lower than the compile time value. In my platform, I want to mute all the logging for a certain part of the execution, and then reenable the logging for later code execution. Thus this is what I did:

/* Suppress all logs. */ tf_log_set_max_level(0); (some code here) /* Restore the compile-time log level. */ tf_log_set_max_level(LOG_LEVEL);

But as the tf_log_set_max_level would only set the log level for a value smaller than LOG_LEVEL (and not equal), the last line fails and I see no log output for the rest of the execution.

If you're wondering, my use case is that in my DRAM initialization sequence, I have some error outputs if the initialization fails, which would be very useful in telling me what have failed. But there are also cases where I can't read the SPD containing the memory info, and thus I have to trial-and-error assume some memory configurations and attempt to do the training. In such case, I would get a lot of error messages and it certainly isn't helpful to see them.

ghost commented 6 years ago

Hello @iq250vip,

but you can only set the log level to a level lower than the compile time value

This is indeed a fair point. We would be happy to accept a contribution for that, please raise a PR with the fix.

Just for completeness, though, let me note that if you use the tf_log_set_max_level() function, the separate BL stages (BL1, BL2 etc.) will keep independent log settings. For example, if you reduce the log level for BL1, then BL2 will still have the compile-time log level.

Kind regards, John

iq250vip commented 6 years ago

Thanks! Just created a pull request for this.